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

0 votes
in ClojureScript by

Since -O and -t take on an enumerated set of values, validate them early.

This can potentially avoid some cryptic error reports. For example, supplying {{adv}} instead of {{advanced}} derails in an odd way:

`
$ clj -m cljs.main -O adv -c chambered.core
WARNING: :preloads should only be specified with :none optimizations
Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :-find-sources of protocol: #'cljs.closure/Compilable found for class: nil

at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
at cljs.closure$eval6819$fn__6833$G__6810__6840.invoke(closure.clj:511)
at cljs.closure$build$fn__7680.invoke(closure.clj:2751)
at cljs.closure$build.invokeStatic(closure.clj:2750)
at cljs.closure$build.invoke(closure.clj:2663)
at cljs.build.api$build.invokeStatic(api.clj:205)
at cljs.build.api$build.invoke(api.clj:189)
at cljs.cli$default_compile.invokeStatic(cli.clj:391)
at cljs.cli$default_compile.invoke(cli.clj:361)
at cljs.cli$compile_opt.invokeStatic(cli.clj:398)
at cljs.cli$compile_opt.invoke(cli.clj:396)
at cljs.cli$main.invokeStatic(cli.clj:527)
at cljs.cli$main.doInvoke(cli.clj:516)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at cljs.main$_main.invokeStatic(main.clj:60)
at cljs.main$_main.doInvoke(main.clj:52)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)

`

3 Answers

0 votes
by

Comment made by: mfikes

The attached patch works, but there are some things I like, and some things I don't like.

It is nice that it declaratively adds specs to the commands and enhances the runtime a little to validate these specs.

But, while this feels like "input validation", another argument is that, if the compiler is going to employ specs, some, like optimization levels could be deeper in the system (which would also catch misconfiguration of compiler option edn).

Anyway, even though I'm not completely happy with the patch, attaching it in case it inspires a better approach.

Here is what you see with the patch for the example in the ticket description.

`
$ clj -m cljs.main -O adv -c chambered.core
Exception in thread "main" clojure.lang.ExceptionInfo: Invalid level: val: "adv" fails spec: :cljs.cli/optmizations predicate: #{"none" "advanced" "whitespace" "simple"}
{}

at clojure.core$ex_info.invokeStatic(core.clj:4739)
at clojure.core$ex_info.invoke(core.clj:4739)
at cljs.cli$add_commands$maybe_wrap_fn__8772$fn__8774.invoke(cli.clj:424)
at cljs.cli$initialize$fn__8714.invoke(cli.clj:235)
at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
at clojure.core$reduce.invokeStatic(core.clj:6747)
at clojure.core$reduce.invoke(core.clj:6730)
at cljs.cli$initialize.invokeStatic(cli.clj:233)
at cljs.cli$initialize.invoke(cli.clj:230)
at cljs.cli$main.invokeStatic(cli.clj:543)
at cljs.cli$main.doInvoke(cli.clj:531)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at cljs.main$_main.invokeStatic(main.clj:60)
at cljs.main$_main.doInvoke(main.clj:52)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)

`

0 votes
by

Comment made by: dnolen

We'd have to bump to 1.9, which we don't really require, I accidentally bumped to 1.9.0 in the {{pom.template.xml}} file.

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