Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing case for Clojure 1.10 syntax errors #3506

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

magnars
Copy link
Contributor

@magnars magnars commented Oct 9, 2023

Loading a buffer sometimes fails silently, since cider-handle-compilation-errors currently does not properly parse all syntax errors.

The pattern matches:

Syntax error compiling at
Syntax error macroexpanding at

but needs to also match:

Syntax error reading source at

This PR fixes this by adding the missing string to the regex.

There is a relevant issue, #3495, but that is larger in scope. Since evaluating code and getting no feedback about syntax errors is a bad experience, I propose that this be fixed without waiting for the additional quality of life improvements in that issue.

I will start work on all the checkboxes below if this seems like a fair change.


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • All code passes the linter (eldev lint) which is based on elisp-lint and includes
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality)

Thanks!

If you're just starting out to hack on CIDER you might find this section of its
manual
extremely useful.

@vemv
Copy link
Member

vemv commented Oct 9, 2023

There are no more cases:

https://github.com/clojure/clojure/blob/6975553804b0f8da9e196e6fb97838ea4e153564/src/jvm/clojure/lang/Compiler.java#L6862-L6870

so LGTM!

Simply make sure to expand test/cider-eval-tests.el.

@magnars magnars force-pushed the patch-2 branch 2 times, most recently from 51e1db8 to 68ca5b4 Compare October 9, 2023 13:59
@magnars
Copy link
Contributor Author

magnars commented Oct 9, 2023

I have added the test. There is one failing check, a timeout on Windows. I don't see any way to trigger just that test for a re-run, so I hope this should be enough to pass. Thanks for verifying that these are the only three cases, @vemv

@@ -55,5 +55,7 @@
:to-equal '("src/haystack/analyzer.clj" 18 1 cider-error-highlight-face "Syntax error compiling clojure.core/let at (src/haystack/analyzer.clj:18:1).\n[1] - failed: even-number-of-forms? at: [:bindings] spec: :clojure.core.specs.alpha/bindings\n"))
(expect (cider-extract-error-info cider-compilation-regexp "Syntax error macroexpanding clojure.core/let at (src/haystack/analyzer.clj:18:1).\n[1] - failed: even-number-of-forms? at: [:bindings] spec: :clojure.core.specs.alpha/bindings\n")
:to-equal '("src/haystack/analyzer.clj" 18 1 cider-error-highlight-face "Syntax error macroexpanding clojure.core/let at (src/haystack/analyzer.clj:18:1).\n[1] - failed: even-number-of-forms? at: [:bindings] spec: :clojure.core.specs.alpha/bindings\n"))
(expect (cider-extract-error-info cider-compilation-regexp "Syntax error reading source clojure.core/let at (src/haystack/analyzer.clj:18:1).\n[1] - failed: even-number-of-forms? at: [:bindings] spec: :clojure.core.specs.alpha/bindings\n")
:to-equal '("src/haystack/analyzer.clj" 18 1 cider-error-highlight-face "Syntax error reading source clojure.core/let at (src/haystack/analyzer.clj:18:1).\n[1] - failed: even-number-of-forms? at: [:bindings] spec: :clojure.core.specs.alpha/bindings\n"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact message I get for e.g. ::::e is: "Syntax error reading source at (/Users/vemv/haystack/src/haystack/parser.cljc:13:0)."

Please let's reflect such a message here - the added test appears to be synthetic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that's an improvement for sure. Done.

Loading a buffer sometimes fails silently, since `cider-handle-compilation-errors` currently does not properly parse all syntax errors.

The pattern matches:

> Syntax error compiling at
> Syntax error macroexpanding at

but needs to also match:

> Syntax error reading source at

This PR fixes this by adding the missing string to the regex.

There is a relevant issue, clojure-emacs#3495, but that is larger in scope. Since evaluating code and getting no feedback about syntax errors is a bad experience, I propose that this be fixed without waiting for the additional quality of life improvements in that issue.
@vemv vemv merged commit cd5cbb3 into clojure-emacs:master Oct 9, 2023
26 checks passed
@vemv
Copy link
Member

vemv commented Oct 9, 2023

Thanks!

@magnars magnars deleted the patch-2 branch October 9, 2023 17:19
@magnars
Copy link
Contributor Author

magnars commented Oct 9, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants