Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

Types defined with deftype/defrecord which have a {{default}} field will incorrectly return {{nil}} with property access. The following example will return {{nil}}.

`
(deftype Foo [default])

(let [foo (Foo. "bar")]
(.-default foo))
`

9 Answers

0 votes
by

Comment made by: noprompt

Patch attached. I should point out that I had to borrow js-reserved from the compiler namespace and the warning message provided hard codes the munged symbol information instead of reusing the compiler's munge fn.

0 votes
by

Comment made by: noprompt

For the sake of history, I should provide more context to this patch (I'm unable to edit the issue title for some reason). It isn't just {{.-default}} it is any field name that is also a JavaScript identifier (eg. {{public}}, {{private}}, {{if}}).

0 votes
by

Comment made by: dnolen

Please lift {{js-reserved}} and any helpers like {{munge}} into the shared namespace {{cljs.util}} so that logic an be shared and hard coding avoided. Thanks.

0 votes
by

Comment made by: noprompt

Are you sure, David? That might make this patch a bit more noisy. If it's not a problem I'm happy to do it.

0 votes
by

Comment made by: dnolen

I'm sure, I'd like to avoid this kind of code duping. Cleaner in the end and better moving forward.

0 votes
by

Comment made by: noprompt

Updated to use new refactorings

0 votes
by

Comment made by: dnolen

The warning is not desirable. Instead we should just munge and ensure property access always works.

0 votes
by

Comment made by: dnolen

Now that we have CLJS-1620, a warning seems like a good answer.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-871 (reported by noprompt)
...