The problem is partly with (hash js/undefined) and partly with (:foo
{}) -- the former is broken on master, the latter returned
js/undefined.

Ticket is here with a fix for the first problem is here:

http://dev.clojure.org/jira/browse/CLJS-330

The ticket description mentions further issues. In particular, (:foo
{}) may or may not need to be "fixed", depending on the desired
handling of null and undefined. nil? currently accepts undefined and
this is very convenient. Perhaps we should therefore make sure
undefined is always interchangeable with null in idiomatic CLJS code
and introduce a null? predicate for place where the distinction might
matter for interop reasons?

Cheers,
Michał


On 3 July 2012 05:47, Michał Marczyk <michal.marc...@gmail.com> wrote:
> I see where the problem is and I've got a possible fix. I'll go ahead
> and open a ticket; I'll be right back with a link.
>
> Cheers,
> Michał
>
>
> On 3 July 2012 04:40, David Nolen <dnolen.li...@gmail.com> wrote:
>> Please open a ticket with these details: 
>> http://dev.clojure.org/jira/browse/CLJS
>>
>> Thanks!
>>
>> David
>>
>> On Mon, Jul 2, 2012 at 10:37 PM, Robert Marianski <r...@marianski.com> wrote:
>>> I'm getting an error when trying to call a multimethod in a certain
>>> scenario. I'm unfortunately not able to reproduce this when running it
>>> as a test case with v8. But, I was able to trim it down to the following
>>> test case which fails for me in a browser (with a connected repl).
>>>
>>>
>>> (defmulti  foo (fn [a b] [(:foo a) (:foo b)]))
>>> (defmethod foo [:foo :bar] [a b] :foobar)
>>> (defmethod foo :default [a b] :default)
>>>
>>> ;; this fails with an error - expecting default case
>>> (foo {} {})
>>> ;; succeeds -> :foobar
>>> (foo {:foo :foo} {:foo :bar})
>>>
>>> However, with slight modifications, it works for me.
>>>
>>> (defmulti  bar (fn [& args] (vec (map :foo args))))
>>> (defmethod bar [:foo :bar] [a b] :foobar)
>>> (defmethod bar :default [a b] :default)
>>>
>>> ;; succeeds -> default case
>>> (bar {} {})
>>>
>>> Interestingly enough, it works with this variation too:
>>> (defmulti  baz (fn [a b] (vector (:foo a) (:foo b))))
>>> (defmethod baz [:foo :bar] [a b] :foobar)
>>> (defmethod baz :default [a b] :default)
>>>
>>> ;; also succeeds -> default case
>>> (baz {} {})
>>>
>>>
>>> The error that I'm getting when it fails is:
>>> obj is undefined
>>> return obj[goog.UID_PROPERTY_] || (obj[goog.UID_PROPERTY_] = 
>>> ++goog.uidCounter_
>>>
>>> (This is in the definition of goog.getUid)
>>>
>>>
>>> I tried to debug a little bit, and it looks like it's failing when
>>> looking up the multimethod in the cache.  The obj is undefined at that
>>> point.
>>>
>>>
>>> Robert
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to