Known issue: http://dev.clojure.org/jira/browse/CLJS-891

The problem is fundamental to Google Closure's approach to namespaces,
you'll encounter this even when you write Closure compatible
JavaScript.

A simple solution is just a compiler warning about such cases. I would
entertain a patch that does minimal munging in this cases - we would
still want to emit some kind of notice that a clash was detected and
that the namespace or definition name was modified to avoid.

David

On Sun, Dec 28, 2014 at 5:15 PM, Andrey Antukh <[email protected]> wrote:
> Hi!
>
> I'm having a strange behavior, and I do not know if it is expected or not.
>
> I'll try to explain the case. I have two files:
>
> foobar/views/contact.cljs
>
> (ns foobar.views.contact)
>
> (defn contact-component
>    [state owner]
>    ...)
>
> foobar/views.cljs
>
> (ns foobar.views
>   (:require [foobar.views.contact :refer [contact-component]]))
>
> (defn contact
>   [state, owner]
>   ...)
>
> This generates that js:
>
> goog.provide("foobar.views.contact");
> // ...
> foobar.views.contact.contact_component = function contact_component(state,
> owner) {
>    // ...
> }
>
> goog.provide("foobar.views");
> // ...
> goog.require("foobar.views.contact");
> // ...
>
> foobar.views.contact = function contact(state, owner) {
>   console.log("test", foobar.views.contact.contact_component);
>   // ...
>   om.core.build.call(null, foobar.views.contact.contact_component,  state)],
> null);
>   // obviously here foobar.views.contact.contact_component is null or
> undefined
>   // because foobar.views.contact is overwriten by this function.
>   // ...
> }
>
> This makes impossible have a function name in one namespace that matches
> with nested namespace name.
> I don't know if this common use case or not (maybe I'm doing it wrong...).
>
> I'm using clojurescript 2511 (with :whitespace optimization)
>
> Cheers.
> Andrey
>
> --
> Andrey Antukh - Андрей Антух - <[email protected]> /
> <[email protected]>
> http://www.niwi.be
> https://github.com/niwibe
>
> --
> Note that posts from new members are moderated - please be patient with your
> first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to