Project

General

Profile

Actions

Bug #21031

closed

Incompatibility with prism and parse.y when eval'ing unnamed forwarding variables

Added by ksss (Yuki Kurihara) 2 days ago. Updated about 20 hours ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-01-13T03:12:28Z master 384e6945ac) +PRISM [arm64-darwin23]
[ruby-core:120628]

Description

Case 1

# t.rb
def foo(*)
  eval("p(*)")
end

foo(1)
$ ruby --parser=prism t.rb
t.rb:4:in 'Kernel#eval': (eval at t.rb:4):1: syntax error found (SyntaxError)
> 1 | p(*)
    |   ^ unexpected `*`; no anonymous rest parameter

	from t.rb:4:in 'Object#foo'
	from t.rb:7:in '<main>'
$ ruby --parser=parse.y t.rb
1

Case 2

# t.rb
def foo(**)
  eval("p(**)")
end

foo(a: 1)
$ ruby --parser=prism t.rb
t.rb:4:in 'Kernel#eval': (eval at t.rb:4):1: syntax error found (SyntaxError)
> 1 | p(**)
    |   ^~ unexpected `**`; no anonymous keyword rest parameter

	from t.rb:4:in 'Object#foo'
	from t.rb:7:in '<main>'
$ ruby --parser=parse.y t.rb
{a: 1}

Case 3

# t.rb
def foo(&)
  eval("p(&)")
end

foo{}
$ ruby --parser=prism t.rb
t.rb:4:in 'Kernel#eval': (eval at t.rb:4):1: syntax error found (SyntaxError)
> 1 | p(&)
    |   ^ unexpected `&`; no anonymous block parameter

	from t.rb:4:in 'Object#foo'
	from t.rb:7:in '<main>'
$ ruby --parser=parse.y t.rb

Case 4

# t.rb
def foo(...)
  eval("p(...)")
end

foo(1, 2, 3)
$ ruby --parser=prism t.rb
t.rb:4:in 'Kernel#eval': (eval at t.rb:4):1: syntax error found (SyntaxError)
> 1 | p(...)
    |   ^~~ unexpected ... when the parent method is not forwarding

	from t.rb:4:in 'Object#foo'
	from t.rb:7:in '<main>'
$ ruby --parser=parse.y t.rb
1
2
3

I expect to the parse.y behavior.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0