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

Fix non-recognized recur inside case in the debugger. #663

Merged
merged 4 commits into from
Feb 5, 2020

Conversation

FiV0
Copy link
Contributor

@FiV0 FiV0 commented Feb 3, 2020

Case expands the non-default branches into a map. This can be seen
when evaluating the following code:

(walk/macroexpand-all '(case i
                         10 (recur (inc i))
                         :halt))

The contains-recur? function did so far not take that into account.

Before submitting a PR make sure the following things have been done:

  • The commits are consistent with our contribution guidelines
  • You've added tests to cover your change(s)
  • All tests are passing (kind of)
    I was able to run tests for 1.9 and 1.10. 1.9 had 1 failure non related to my code and 1.10 none.
    I was unable to run the tests for 1.8 because of some leiningen issue.
  • The new code is not generating reflection warnings
  • You've updated the README (if adding/changing middleware)

This should be fixing cider#2772

Case expands the non-default branches into a map. This can be seen
when evaluating the following code:
`(walk/macroexpand-all '(case i
                      1 "hello"
                      "world"))`
The `contains-recur?` did so far not take that into account.
The previous `contains-recur?` did not handle `case` when a map return
value was given correctly. Example:

(case i
   nil {:foo :bar}
   :fuss)

This commit solve this.
;; this depends on internal logic
(map? form) (some contains-recur? (vals form))
(vector? form) (some contains-recur? (seq form))
:else false))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this is the best way to handle the issue. I am open for other suggestions. I mean normally a recur should only appear in a map when used inside a case.

Copy link
Member

Choose a reason for hiding this comment

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

I think your approach is pretty reasonable, but perhaps @Malabarba or @vspinu have some better ideas.

@bbatsov
Copy link
Member

bbatsov commented Feb 5, 2020

The code looks good to me overall, we just need a changelog entry.

P.S. I really appreciate that you took the time to get familiar with the debugger and tackle some issues there! 🙇

@FiV0
Copy link
Contributor Author

FiV0 commented Feb 5, 2020

@bbatsov I don't know if you saw it, but I also left a longer comment in clojure-emacs/cider#2772 outlining some more general problem in the debugger. No pressure to reply soon. Just wanted to make sure you had seen it. I can also open an issue here for discussion as it is more related to cider-nrepl than to the cider emacs side.

@bbatsov
Copy link
Member

bbatsov commented Feb 5, 2020

Just replied there as well.

@bbatsov bbatsov merged commit ba4a5b6 into clojure-emacs:master Feb 5, 2020
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