Project

General

Profile

Actions

Bug #21988

closed

`return a, &b` should be syntax error

Bug #21988: `return a, &b` should be syntax error

Added by tompng (tomoya ishida) 1 day ago. Updated 1 day ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +YJIT +MN +PRISM [arm64-darwin24]
[ruby-core:125218]

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 Actions #2

  • 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]

https://github.com/ruby/prism/commit/2dd20183ad

Actions

Also available in: PDF Atom