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

Fully evaluate lazy seqs when macroexpanding #887

Closed
wants to merge 3 commits into from

Conversation

yuhan0
Copy link
Contributor

@yuhan0 yuhan0 commented Jul 13, 2024

Fixes #886

Note: I also added a doall in what seemed like the right spot for the cljs expander, but wasn't able to easily test whether it had any effect. There's no existing test coverage for that code path so I'm fine with removing it in case it breaks anything.


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
  • You've updated the README
  • Middleware documentation is up to date
    • Please check out and modify the cider.nrepl ns which has all middleware documentation.
    • Run lein docs afterwards, and commit the results.

Thanks!

Copy link
Member

@vemv vemv left a comment

Choose a reason for hiding this comment

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

Thanks!

LGTM

@yuhan0
Copy link
Contributor Author

yuhan0 commented Jul 13, 2024

Oh.. I only ran lein test, good thing the CI caught this bug. Somehow I couldn't replicate the test failure locally using make tools-deps-test but hopefully the following commit should fix it.

@alexander-yakushev
Copy link
Member

Unfortunately, it is not enough to call doall to force all internal parts of the constructed sexp. See https://clojure-goes-fast.com/blog/clojures-deadly-sin/#no-way-to-force-everything.

Try making a test case where the lazy part of the macro is somewhere deeper in the top-level expression. I think you'll have to print-str or something like that.

@alexander-yakushev
Copy link
Member

This PR is superseded by #894 which should handle the lazy expansion problem fully besides other things.

@bbatsov bbatsov closed this Aug 21, 2024
@alexander-yakushev
Copy link
Member

@yuhan0 Thanks for reporting the issue and proposing a fix! This led to uncovering a deeper problem with macroexpansion middleware.

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.

Macroexpansion with lazy seqs occurs in the wrong ns
4 participants