Skip to content

RubyParser translation for stabby lambdas with it#3616

Merged
kddnewton merged 3 commits into
ruby:mainfrom
presidentbeef:it_in_stabby_lambda
Aug 1, 2025
Merged

RubyParser translation for stabby lambdas with it#3616
kddnewton merged 3 commits into
ruby:mainfrom
presidentbeef:it_in_stabby_lambda

Conversation

@presidentbeef

Copy link
Copy Markdown
Contributor

Similar to #3409

However, I'm a little confused and I may be missing something.

The tests pass (as you can see) and the expected output in Prism's test is:

s(:iter, s(:lambda), s(:args), (:call, nil, :it))

However, when I run RubyParser myself, I get

3.4.2 :002 > RubyParser.new.parse('-> { it }')
 => s(:iter, s(:lambda), 0, s(:call, nil, :it)) 

I honestly can't explain the discrepancy. 😕

@Earlopain

Copy link
Copy Markdown
Collaborator

I honestly can't explain the discrepancy

This one causes it, can't tell why though

Sexp.prepend(
Module.new do
def ==(other)
super && line == other.line && file == other.file # && line_max == other.line_max
end
end
)

Overall it would still be parsed as 3.3 since there is no released version of ruby_parser to compare against. Though that monkeypatch seems to change some things.

@presidentbeef

Copy link
Copy Markdown
Contributor Author

AHHH thank you @Earlopain!

Prism should not do this, because there is code in RubyParser where it is comparing a Sexp with a line/file to a fresh Sexp with no line/file and changing its behavior as a result (example).

Updated this PR to fix.

@kddnewton kddnewton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice!

@kddnewton
kddnewton merged commit 399d3be into ruby:main Aug 1, 2025
59 of 60 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.

3 participants