Skip to content

Conversation

@Earlopain
Copy link
Collaborator

@Earlopain Earlopain commented Jan 20, 2026

You're supposed to return the first argument.

# Before
[[:stmts_new], [:rescue_mod, nil, nil], [:stmts_add, nil, nil], [:program, nil]]
# After
[[:stmts_new], [:rescue_mod, "1", "2"], [:stmts_add, nil, "1"], [:program, nil]]

The correct result would be:
[[:rescue_mod, "1", "2"], [:stmts_new], [:stmts_add, nil, "1"], [:program, nil]]

But the order depends on the prism AST so it seems very difficult to match.

Ref: #3838

@Earlopain
Copy link
Collaborator Author

Somewhat unsure about this fix but it seems to work very well.

Comment on lines 3448 to +3454
def _dispatch_0; end
def _dispatch_1(_); end
def _dispatch_2(_, _); end
def _dispatch_3(_, _, _); end
def _dispatch_4(_, _, _, _); end
def _dispatch_5(_, _, _, _, _); end
def _dispatch_7(_, _, _, _, _, _, _); end
def _dispatch_1(arg); arg end
def _dispatch_2(arg, _); arg end
def _dispatch_3(arg, _, _); arg end
def _dispatch_4(arg, _, _, _); arg end
def _dispatch_5(arg, _, _, _, _); arg end
def _dispatch_7(arg, _, _, _, _, _, _); arg end
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I wonder why we didn't/don't just copy that part from upstream.
Maybe the unused variables cause warnings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, nice. I was mostly just guessing but this makes it pretty clear.

Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

You're supposed to return the first argument.
```rb
# Before
[[:stmts_new], [:rescue_mod, nil, nil], [:stmts_add, nil, nil], [:program, nil]]
# After
[[:stmts_new], [:rescue_mod, "1", "2"], [:stmts_add, nil, "1"], [:program, nil]]
```

The correct result would be:
`[[:rescue_mod, "1", "2"], [:stmts_new], [:stmts_add, nil, "1"], [:program, nil]]`

But the order depends on the prism AST so it seems very difficult to match.
@Earlopain Earlopain force-pushed the ripper-events-return-value branch from 6aa3a04 to 94e0107 Compare January 20, 2026 19:34
@eregon eregon merged commit 63719d8 into ruby:main Jan 20, 2026
66 checks passed
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.

Ripper translation layer relies on upstream Ripper and is not fully compatible

2 participants