Share your thoughts in the 2024 State of Clojure Survey!

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

0 votes
in ClojureScript by

Defrecord produces code that's incompatible with ECMASCRIPT3 language:

(defrecord Query [with in])

`
Compiling "target/main.js" from ["src"]...
Jul 14, 2017 6:58:14 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/prokopov/work/cljs-test/target/cljsbuild-compiler-0/cljs_test/core.js:117: WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.
return (!((other13203 == null))) && ((this13202$1.constructor === other13203.constructor)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202__$1.with,other13203.with)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.in,other13203.in)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.extmap,other13203.__extmap));

                                                                                                                                                        ^

Jul 14, 2017 6:58:14 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/prokopov/work/cljs-test/target/cljsbuild-compiler-0/cljs_test/core.js:117: WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.
return (!((other13203 == null))) && ((this13202$1.constructor === other13203.constructor)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202__$1.with,other13203.with)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.in,other13203.in)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.extmap,other13203.__extmap));

                                                                                                                                                                        ^

Jul 14, 2017 6:58:14 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/prokopov/work/cljs-test/target/cljsbuild-compiler-0/cljs_test/core.js:117: WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.
return (!((other13203 == null))) && ((this13202$1.constructor === other13203.constructor)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202__$1.with,other13203.with)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.in,other13203.in)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.extmap,other13203.__extmap));

                                                                                                                                                                                                                                              ^

Jul 14, 2017 6:58:14 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: /Users/prokopov/work/cljs-test/target/cljsbuild-compiler-0/cljs_test/core.js:117: WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.
return (!((other13203 == null))) && ((this13202$1.constructor === other13203.constructor)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202__$1.with,other13203.with)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.in,other13203.in)) && (cljs.core.EQ.cljs$core$IFn$_invoke$arity$2(this13202$1.extmap,other13203.__extmap));

                                                                                                                                                                                                                                                           ^

Jul 14, 2017 6:58:14 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 4 warning(s)
Successfully compiled "target/main.js" in 6.224 seconds.
`

Probably there should be some name escaping happening? I see that {{(defn with [])}} is compiled as {{cljs-test.core.with$}}. Should we do the same for records?

4 Answers

0 votes
by

Comment made by: dnolen

The problem has less to do with records than how to handle reserved names. As far as I'm concerned the Closure warnings are sufficient, but if somebody wants to devise a warning patch that warns on using reserved fields names on deftpye/record when the output language is ES3, then be my guest.

0 votes
by

Comment made by: dnolen

Related CLJS-871

0 votes
by
_Comment made by: tonsky_

Is there any reason why CLJS defaults to language_in=ES3? Shouldn’t CLJS lock in the version of JS it outputs? As I understand, programmers have no control over how JS looks, but CLJS compiler has knowledge and control over what version of JS it outputs (and feeds into Closure)? In other words, why not set language_in to ES5 by default?
0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2237 (reported by tonsky)
...