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}]
Actions

Also available in: PDF Atom