Actions
Bug #21988
closed`return a, &b` should be syntax error
Bug #21988:
`return a, &b` should be syntax error
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +YJIT +MN +PRISM [arm64-darwin24]
Description
return a, &b is syntax error in parse.y, but accepted in Prism
Prism.parse_success?('return a, &b')
#=> true
RubyVM::AbstractSyntaxTree.parse('return a, &b')
#=> block argument should not be given (SyntaxError)
When evaluated, block part is just ignored
->{return (p :arg_part), **(p kwsplat_part:1), &(p :block_part)}.call
# :arg_part
# {kwsplat_part: 1}
#=> [:arg_part, {kwsplat_part: 1}]
Updated by Earlopain (Earlopain _) 1 day ago
- Assignee set to prism
Updated by Earlopain (Earlopain _) 1 day ago
- Status changed from Open to Closed
Applied in changeset git|51a3f0847782095340df5dbc8fb87450dbc1fbe7.
[ruby/prism] Reject return and similar with block pass argument
Same handling as for yield. Fixes [Bug #21988]
Actions