summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y2
-rw-r--r--prism/prism.c1
-rw-r--r--test/prism/fixtures/methods.txt2
-rw-r--r--test/prism/snapshots/methods.txt17
-rw-r--r--test/ruby/test_compile_prism.rb9
-rw-r--r--test/ruby/test_syntax.rb1
6 files changed, 12 insertions, 20 deletions
diff --git a/parse.y b/parse.y
index 58e39e8f2d..3665f9b7c0 100644
--- a/parse.y
+++ b/parse.y
@@ -4263,7 +4263,7 @@ block_arg : tAMPER arg_value
}
| tAMPER
{
- forwarding_arg_check(p, idFWD_BLOCK, 0, "block");
+ forwarding_arg_check(p, idFWD_BLOCK, idFWD_ALL, "block");
$$ = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, &@1), &@$);
/*% ripper: Qnil %*/
}
diff --git a/prism/prism.c b/prism/prism.c
index a0ab6d7cee..93328247e0 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -13486,7 +13486,6 @@ parse_parameters(
update_parameter_state(parser, &parser->current, &order);
parser_lex(parser);
- parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_FORWARDING_BLOCK;
parser->current_scope->parameters |= PM_SCOPE_PARAMETERS_FORWARDING_ALL;
pm_forwarding_parameter_node_t *param = pm_forwarding_parameter_node_create(parser, &parser->previous);
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