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 expecty macro #307

Merged
merged 3 commits into from
Sep 19, 2024
Merged

Fix expecty macro #307

merged 3 commits into from
Sep 19, 2024

Conversation

pawelsadlo
Copy link
Contributor

@pawelsadlo pawelsadlo commented Sep 13, 2024

trying to fix #305

It seems that AST that our macro produces is spliced into AST of the expression provided to Expecty.expect

Then it tries to evaluate this composed AST, but it fails, I'm not exactly sure why, maybe some local vals in macro arent simply available in the scope where expecty evaluates them.

I think Expecty.expect should expand only AST of expression provided to it (and do not follow macros and splice ASTs generated by them)

This PR rewrites macro a little bit not to use values calculated in macro itself (it also removes potentially problematic Expr.apply call). As a consequence we have to make a segmentsFromString public, because call to it is also inlined.

This change fixes compilation of expecty macros, but due to the fact that expecty expands AST too much, its assertion clues will be malformed anyway, but I don't think we would be able to solve this in os-lib.

Note:
Using scala 2 there is no bug.

@pawelsadlo pawelsadlo marked this pull request as draft September 13, 2024 22:10
moving Expecty tests to separate Suite,
running expecty tests only on jvm
@pawelsadlo pawelsadlo marked this pull request as ready for review September 14, 2024 13:46
@pawelsadlo pawelsadlo changed the title WIP - Fix expecty macro Fix expecty macro Sep 14, 2024
@lihaoyi
Copy link
Member

lihaoyi commented Sep 19, 2024

@pawelsadlo this looks good, thanks!

@lihaoyi lihaoyi merged commit 92c5a94 into com-lihaoyi:main Sep 19, 2024
8 checks passed
@lefou lefou added this to the after 0.10.7 milestone Sep 19, 2024
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.

[Bug] os-lib 0.10.7 breaks expecty macro in weaver
3 participants