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

Closes #23. Add support for operational assignments. #30

Merged
merged 1 commit into from
Nov 6, 2017

Conversation

faultyserver
Copy link
Member

The interpreter now nows how to visit OpAssign nodes, including the conditional assignment variants, ||= and &&=. For normal cases, the node is simple rewritten from target op= value to target = target op value. For conditional assignments, the expansion is closest to target op target = value, but with some safeguarding to avoid raising errors when target does not exist in the current scope (it will be initialized to nil).

This rewriting also works with Calls, where the assignments are rewritten to call the assignment variant of the method (i.e., #{method}=) rather than performing a SimpleAssign.

See #23 for more details.

The interpreter now nows how to visit `OpAssign` nodes, including the conditional assignment variants, `||=` and `&&=`. For normal cases, the assignments are rewritten from `a op= b` to `a = a op b`. For conditional assignments, the expansion is closest to `a op a = b`, but with some safeguarding to avoid raising errors when `a` does not exist (it will be initialized to `nil`).
@faultyserver faultyserver merged commit 17a557c into master Nov 6, 2017
@faultyserver faultyserver deleted the 23_operational_assignments branch November 6, 2017 14:01
@faultyserver faultyserver added this to the v0.2.0 milestone Nov 6, 2017
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.

1 participant