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 edge case for lambda with no params #314

Merged
merged 1 commit into from
Oct 30, 2024
Merged

Conversation

egiurleo
Copy link

@egiurleo egiurleo commented Oct 30, 2024

Related to #316

Motivation

We didn't have a test case for lambdas with no block parameters. Sorbet represents this case with an empty Args node, so we can check whether the parameters field inside a PM_BLOCK_PARAMETERS_NODE is a nullptr, and then return early if so.

Test plan

See included automated tests.

@egiurleo egiurleo self-assigned this Oct 30, 2024
Copy link

@amomchilov amomchilov left a comment

Choose a reason for hiding this comment

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

Nice find!

@@ -19,3 +19,6 @@ def method_returning_lambda
-> { 123 }
end
end

# Empty lambda parameters
->() { 1 + 2 }
Copy link

@amomchilov amomchilov Oct 30, 2024

Choose a reason for hiding this comment

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

Interesting that there's a difference between ->() {} and -> {}

@egiurleo egiurleo merged commit 57bba3a into prism Oct 30, 2024
1 check passed
@egiurleo egiurleo deleted the emily/lambda-no-params branch October 30, 2024 18:01
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.

2 participants