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

Allow executing OpAssign (+=, ||=, etc.) inside macros #9409

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

asterite
Copy link
Member

@asterite asterite commented Jun 2, 2020

Fixes #9356

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:lang:macros labels Jun 2, 2020
Copy link
Member

@jhass jhass left a comment

Choose a reason for hiding this comment

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

❤️ I ran into this before.

@@ -318,6 +318,10 @@ module Crystal
false
end

def visit(node : OpAssign)
@program.normalize(node).accept(self)
Copy link
Member

Choose a reason for hiding this comment

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

Just for my own learning; last time you implemented this in cf35077 you had false as the return value. What's the reasoning behind including that or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot, thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the visit methods also return true?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

@bcardiff bcardiff added this to the 0.35.0 milestone Jun 5, 2020
@bcardiff bcardiff merged commit c4b87dc into crystal-lang:master Jun 5, 2020
@asterite asterite deleted the bug/op-assign-in-macros branch June 5, 2020 13:09
grepsedawk added a commit to grepsedawk/athena that referenced this pull request Feb 21, 2022
crystal-lang/crystal#9409 was merged, adding support for ||= in macros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:lang:macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: can't execute OpAssign in a macro
5 participants