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 unexpected error when or-asgn/and-asgn #517

Merged
merged 1 commit into from
Mar 20, 2022
Merged

Conversation

ksss
Copy link
Contributor

@ksss ksss commented Mar 20, 2022

Fix #515

or-asgn/and-asgn may differ in the number of children under the send node.

$ ruby-parse --legacy -e 'a=[]; a[0] ||= 3'
(begin
  (lvasgn :a
    (array))
  (or-asgn
    (send
      (lvar :a) :[]
      (int 0)) # <= `(int 0)` is asgn.children[2]
    (int 3)))

$ ruby-parse --legacy -e 'self.a ||= 3'
(or-asgn
  (send
    (self) :a) # <= not have asgn.children[2]
  (int 3))

This PR support both pattern.

Copy link
Owner

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

Nice catch! 👍 👏

@soutaro soutaro merged commit 079b718 into soutaro:master Mar 20, 2022
@ksss ksss deleted the or-and-asgn branch March 20, 2022 12:59
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.

Unexpected error when or-asgn/and-asgn
2 participants