Support ruby 3.1 :args_forward shape change #1431
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently yard errors when tries to parse method with args forwarding using Ruby 3.1:
This is happening because Ruby 3.1 changes
params
statement for a method with args forwarding from:Reference:
https://kddnewton.com/2022/01/08/ripper-changelog-3.1.0.html#argument-forwarding
to:
So the
block_param
wrongly assumes that:&
is an explicit block argument.I don't think there is an issue with
block_param
method, the "shape" of the statement stays the same and the last value in the array is references block param, it's just in this particular case the block param is "anonymous" or "implicit" if I may call it like that.So I'm adding additional
args_forward
check to avoid processing:&
block.args_forward
method works for both Ruby 3.1 and older versions even though we don't necessarily need it for Ruby lower than 3.1Also added test for the anonymous block forwarding. It's not related to the issue but I thought it can't hurt having it just in case
Completed Tasks
bundle exec rake
locally (if code is attached to PR).