r/Clojure • • Apr 11 '19

Clojure 1.10.1-beta2 is now available

https://clojure.org/community/devchangelog#_1_10_1_beta2_apr_11_2019
81 Upvotes

17 comments sorted by

View all comments

15

u/alexdmiller Apr 11 '19 edited Apr 11 '19

Two small bumps - slight change in error reporting in CLJ-2497 and an error phase bug we noticed in CLJ-2499.

  • CLJ-2497 Put error report location on its own line

  • CLJ-2499 Some compiler expr evals report as wrong phase

Please try this release as we do not expect to put much, if anything, else into 1.10.1 before release. The error reporting differences in 1.10.1-beta1 are a significantly different experience though, particularly if using clj as a runner (not REPL), or lein, etc. While a couple people have tried it, we have not heard many experience reports on this aspect and would love to hear more.

39

u/alexdmiller Apr 11 '19 edited Apr 11 '19

To make the error reporting difference more concrete, say you misspell `defn` as `dfn` in a leiningen project.

With Clojure 1.10.0:

$ lein compile
Compiling err.core
Syntax error compiling at (err/core.clj:5:1).
Exception in thread "main" Syntax error compiling at (err/core.clj:5:1).
	at clojure.lang.Compiler.analyze(Compiler.java:6808)
	at clojure.lang.Compiler.analyze(Compiler.java:6745)
	at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3820)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7108)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.analyze(Compiler.java:6745)
	at clojure.lang.Compiler.compile1(Compiler.java:7725)
	at clojure.lang.Compiler.compile(Compiler.java:7797)
	at clojure.lang.RT.compile(RT.java:415)
	at clojure.lang.RT.load(RT.java:461)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$compile$fn__6829.invoke(core.clj:6136)
	at clojure.core$compile.invokeStatic(core.clj:6136)
	at clojure.core$compile.invoke(core.clj:6128)
	at user$eval155$fn__164.invoke(form-init17873960244841819464.clj:1)
	at user$eval155.invokeStatic(form-init17873960244841819464.clj:1)
	at user$eval155.invoke(form-init17873960244841819464.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.Compiler.loadFile(Compiler.java:7573)
	at clojure.main$load_script.invokeStatic(main.clj:452)
	at clojure.main$init_opt.invokeStatic(main.clj:454)
	at clojure.main$init_opt.invoke(main.clj:454)
	at clojure.main$initialize.invokeStatic(main.clj:485)
	at clojure.main$null_opt.invokeStatic(main.clj:519)
	at clojure.main$null_opt.invoke(main.clj:516)
	at clojure.main$main.invokeStatic(main.clj:598)
	at clojure.main$main.doInvoke(main.clj:561)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: dfn in this context
	at clojure.lang.Util.runtimeException(Util.java:221)
	at clojure.lang.Compiler.resolveIn(Compiler.java:7413)
	at clojure.lang.Compiler.resolve(Compiler.java:7357)
	at clojure.lang.Compiler.analyzeSymbol(Compiler.java:7318)
	at clojure.lang.Compiler.analyze(Compiler.java:6768)
	... 37 more
Compilation failed: Subprocess failed

With Clojure 1.10.1-beta2:

$ lein compile
Compiling err.core
Syntax error compiling at (err/core.clj:5:1).
Syntax error compiling at (err/core.clj:5:1).
Unable to resolve symbol: dfn in this context

Full report at:
/var/folders/2k/2l7ch1xn7lb5gj86tgp1ygww0000gn/T/clojure-3724210784369662770.edn
Compilation failed: Subprocess failed

The full stack and other info is recorded in the linked .edn file.

The repeated syntax error line is because both lein and clojure.main are printing the error. There are a variety of options to fix that, but they are really up to what Leiningen wants to do. In my opinion, Leiningen should be wrapping the subprocess entry point more and not be dependent on what clojure.main does as a runner. The error reporting facility is provided as a separate function that Leiningen could use if desired (see new http://clojure.github.io/clojure/branch-master/clojure.main-api.html#clojure.main/report-error).

This affects anything in lein that shells to a subprocess calling clojure.main (which is many things - compile, test, run, ring server, etc).

1

u/jeronimo78543 Apr 15 '19

It looks great indeed!

However, for CI, is there a way to turn the verbose error back on? The stacktrace is otherwise not available in environment where it might provide essential information.

1

u/alexdmiller Apr 15 '19

As mentioned elsewhere in this thread, yes.