From: "Eregon (Benoit Daloze) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "Eregon (Benoit Daloze)" <noreply@ruby-lang.org>
Subject: [ruby-core:120630] [Ruby master Bug#21031] Incompatibility with prism and parse.y when eval'ing unnamed forwarding variables
Date: Mon, 13 Jan 2025 11:38:35 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-111459.20250113113834.9586@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-21031.20250113105426.9586@ruby-lang.org>
Issue #21031 has been updated by Eregon (Benoit Daloze).
As a note, I checked and the `*` and **` examples (Case 1 & 2) work in 3.2 and 3.3.
Case 3 / `&` seems incorrect though, as it should print the block but doesn't.
----------------------------------------
Bug #21031: Incompatibility with prism and parse.y when eval'ing unnamed forwarding variables
https://bugs.ruby-lang.org/issues/21031#change-111459
* Author: ksss (Yuki Kurihara)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-01-13T03:12:28Z master 384e6945ac) +PRISM [arm64-darwin23]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
## Case 1
```rb
# 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
```rb
# 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
```rb
# 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
```rb
# 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.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
next prev parent reply other threads:[~2025-01-13 11:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 10:54 [ruby-core:120628] " ksss (Yuki Kurihara) via ruby-core
2025-01-13 11:29 ` [ruby-core:120629] " Eregon (Benoit Daloze) via ruby-core
2025-01-13 11:38 ` Eregon (Benoit Daloze) via ruby-core [this message]
2025-01-13 16:37 ` [ruby-core:120635] " jeremyevans0 (Jeremy Evans) via ruby-core
2025-01-13 17:09 ` [ruby-core:120636] " Eregon (Benoit Daloze) via ruby-core
2025-02-14 5:07 ` [ruby-core:121017] " k0kubun (Takashi Kokubun) via ruby-core
2025-02-14 5:23 ` [ruby-core:121035] " k0kubun (Takashi Kokubun) via ruby-core
2025-02-14 18:28 ` [ruby-core:121055] " k0kubun (Takashi Kokubun) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-111459.20250113113834.9586@ruby-lang.org \
--to=ruby-core@ml.ruby-lang.org \
--cc=noreply@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).