diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-04-12 16:07:49 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-04-12 16:07:49 +0900 |
commit | e36988450e9e9ccccb41c72135f1e57790920668 (patch) | |
tree | 2a671b2f464701bedbdc69ded905f90c7991a0b3 /test | |
parent | 971b552735f46cbda7345e8de60a2037ee10e259 (diff) |
[Bug #20423] Disallow anonymous block within argument forwarding
Diffstat (limited to 'test')
-rw-r--r-- | test/prism/fixtures/methods.txt | 2 | ||||
-rw-r--r-- | test/prism/snapshots/methods.txt | 17 | ||||
-rw-r--r-- | test/ruby/test_compile_prism.rb | 9 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 1 |
4 files changed, 11 insertions, 18 deletions
diff --git a/test/prism/fixtures/methods.txt b/test/prism/fixtures/methods.txt index 0d2286056f..4bfd976eda 100644 --- a/test/prism/fixtures/methods.txt +++ b/test/prism/fixtures/methods.txt @@ -175,7 +175,7 @@ def f x:!a; end def foo x:%(xx); end def foo(...) - bar(&) + bar(...) end def foo(bar = (def baz(bar) = bar; 1)) = 2 diff --git a/test/prism/snapshots/methods.txt b/test/prism/snapshots/methods.txt index 24567d24df..22580494a4 100644 --- a/test/prism/snapshots/methods.txt +++ b/test/prism/snapshots/methods.txt @@ -1908,21 +1908,22 @@ │ │ │ @ ForwardingParameterNode (location: (177,8)-(177,11)) │ │ └── block: ∅ │ ├── body: - │ │ @ StatementsNode (location: (178,2)-(178,7)) + │ │ @ StatementsNode (location: (178,2)-(178,10)) │ │ └── body: (length: 1) - │ │ └── @ CallNode (location: (178,2)-(178,7)) + │ │ └── @ CallNode (location: (178,2)-(178,10)) │ │ ├── flags: ignore_visibility │ │ ├── receiver: ∅ │ │ ├── call_operator_loc: ∅ │ │ ├── name: :bar │ │ ├── message_loc: (178,2)-(178,5) = "bar" │ │ ├── opening_loc: (178,5)-(178,6) = "(" - │ │ ├── arguments: ∅ - │ │ ├── closing_loc: (178,7)-(178,8) = ")" - │ │ └── block: - │ │ @ BlockArgumentNode (location: (178,6)-(178,7)) - │ │ ├── expression: ∅ - │ │ └── operator_loc: (178,6)-(178,7) = "&" + │ │ ├── arguments: + │ │ │ @ ArgumentsNode (location: (178,6)-(178,9)) + │ │ │ ├── flags: ∅ + │ │ │ └── arguments: (length: 1) + │ │ │ └── @ ForwardingArgumentsNode (location: (178,6)-(178,9)) + │ │ ├── closing_loc: (178,9)-(178,10) = ")" + │ │ └── block: ∅ │ ├── locals: [] │ ├── def_keyword_loc: (177,0)-(177,3) = "def" │ ├── operator_loc: ∅ diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index eef909eb07..d13b150f93 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1839,15 +1839,6 @@ end o.bar { :ok } RUBY - - # Test anonymous block forwarding from argument forwarding - assert_prism_eval(<<~RUBY) - o = Object.new - def o.foo = yield - def o.bar(...) = foo(&) - - o.bar { :ok } - RUBY end def test_BlockLocalVariableNode diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 7cc5e542a7..44162f06cb 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -190,6 +190,7 @@ class TestSyntax < Test::Unit::TestCase assert_syntax_error("def f(...); g(0, *); end", /no anonymous rest parameter/) assert_syntax_error("def f(...); g(**); end", /no anonymous keyword rest parameter/) assert_syntax_error("def f(...); g(x: 1, **); end", /no anonymous keyword rest parameter/) + assert_syntax_error("def f(...); g(&); end", /no anonymous block parameter/) end def test_newline_in_block_parameters |