diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f1305d44..956b811a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +### Changes + +- [#3521](https://github.com/clojure-emacs/cider/issues/3521): Expand `cider-clojure-compilation-regexp` to also match e.g. `Unexpected error (ExceptionInfo) macroexpanding defmulti at (src/ns.clj:1:1).`. + ## 1.8.2 (2023-10-15) ### Changes diff --git a/cider-eval.el b/cider-eval.el index 360866a73..2f7745d6d 100644 --- a/cider-eval.el +++ b/cider-eval.el @@ -558,19 +558,31 @@ It delegates the actual error content to the eval or op handler." ;; old and the new format, by utilizing a combination of two different regular ;; expressions. -(defconst cider-clojure-1.10-error `(sequence - "Syntax error " - (minimal-match (zero-or-more anything)) - (or "compiling " - "macroexpanding " - "reading source ") - (minimal-match (zero-or-more anything)) - "at (" - (group-n 2 (minimal-match (zero-or-more anything))) - ":" - (group-n 3 (one-or-more digit)) - (optional ":" (group-n 4 (one-or-more digit))) - ").")) +(defconst cider-clojure-1.10--location `("at (" + (group-n 2 (minimal-match (zero-or-more anything))) + ":" + (group-n 3 (one-or-more digit)) + (optional ":" (group-n 4 (one-or-more digit))) + ").")) + +(defconst cider-clojure-1.10-error (append `(sequence + "Syntax error " + (minimal-match (zero-or-more anything)) + (or "compiling " + "macroexpanding " + "reading source ") + (minimal-match (zero-or-more anything))) + cider-clojure-1.10--location)) + +(defconst cider-clojure-unexpected-error (append `(sequence + "Unexpected error (" + (minimal-match (one-or-more anything)) + ") " + (or "compiling " + "macroexpanding " + "reading source ") + (minimal-match (one-or-more anything))) + cider-clojure-1.10--location)) (defconst cider-clojure-1.9-error `(sequence (zero-or-more anything) @@ -591,23 +603,19 @@ It delegates the actual error content to the eval or op handler." (optional ":" (group-n 4 (one-or-more digit))) " - ")) - (defconst cider-clojure-compilation-regexp (eval `(rx bol (or ,cider-clojure-1.9-error ,cider-clojure-warning - ,cider-clojure-1.10-error)) + ,cider-clojure-1.10-error + ,cider-clojure-unexpected-error)) t) "A few example values that will match: \"Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - \" \"CompilerException java.lang.RuntimeException: Unable to resolve symbol: \\ lol in this context, compiling:(/foo/core.clj:10:1)\" -\"Syntax error compiling at (src/workspace_service.clj:227:3).\"") - -(replace-regexp-in-string cider-clojure-compilation-regexp - "" - "Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - call to java.lang.Integer ctor can't be resolved.") - +\"Syntax error compiling at (src/workspace_service.clj:227:3).\" +\"Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).\"") (defvar cider-compilation-regexp (list cider-clojure-compilation-regexp 2 3 4 '(1)) diff --git a/doc/modules/ROOT/pages/usage/dealing_with_errors.adoc b/doc/modules/ROOT/pages/usage/dealing_with_errors.adoc index 000707195..82bfd72c8 100644 --- a/doc/modules/ROOT/pages/usage/dealing_with_errors.adoc +++ b/doc/modules/ROOT/pages/usage/dealing_with_errors.adoc @@ -23,6 +23,8 @@ temporary overlay or in the echo area: (setq cider-show-error-buffer nil) ---- +NOTE: you will only see the overlay if `cider-use-overlays` is non-nil. + Starting from CIDER 1.8.0, only runtime exceptions (and not compilation errors) will cause a stacktrace buffer to be shown. This better follows Clojure 1.10's https://clojure.org/reference/repl_and_main#_at_repl[intended semantics]. diff --git a/test/cider-error-parsing-tests.el b/test/cider-error-parsing-tests.el index a73e08005..d53e823d5 100644 --- a/test/cider-error-parsing-tests.el +++ b/test/cider-error-parsing-tests.el @@ -135,4 +135,10 @@ (expect clojure-1.10-compiler-error :to-match cider-clojure-compilation-regexp) (expect (progn (string-match cider-clojure-compilation-regexp clojure-1.10-compiler-error) (match-string 2 clojure-1.10-compiler-error)) - :to-equal "src/ardoq/service/workspace_service.clj")))) + :to-equal "src/ardoq/service/workspace_service.clj"))) + (it "Recognizes a clojure 'Unexpected error' message" + (let ((clojure-1.10-compiler-error "Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).")) + (expect clojure-1.10-compiler-error :to-match cider-clojure-compilation-regexp) + (expect (progn (string-match cider-clojure-compilation-regexp clojure-1.10-compiler-error) + (match-string 2 clojure-1.10-compiler-error)) + :to-equal "src/haystack/parser.cljc"))))