diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-12-23 18:07:37 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-12-25 14:44:04 +0900 |
commit | a9f096183170810ac6ce32b20d7810d11a51b5f5 (patch) | |
tree | dbb004a3f8cd5a9269f42bf9ecff5b0f40787aa5 /test/ruby/test_syntax.rb | |
parent | b641b7e640b90292e8091348ca05def0a16904a8 (diff) |
[Feature #19370] Prohibit nesting anonymous parameter forwarding
Diffstat (limited to 'test/ruby/test_syntax.rb')
-rw-r--r-- | test/ruby/test_syntax.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 7bbb14e323..33fcc6a1e0 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -76,6 +76,7 @@ class TestSyntax < Test::Unit::TestCase def test_anonymous_block_forwarding assert_syntax_error("def b; c(&); end", /no anonymous block parameter/) + assert_syntax_error("def b(&) ->(&) {c(&)} end", /anonymous block parameter is also used/) assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(&); c(&) end @@ -143,6 +144,9 @@ class TestSyntax < Test::Unit::TestCase def test_anonymous_rest_forwarding assert_syntax_error("def b; c(*); end", /no anonymous rest parameter/) assert_syntax_error("def b; c(1, *); end", /no anonymous rest parameter/) + assert_syntax_error("def b(*) ->(*) {c(*)} end", /anonymous rest parameter is also used/) + assert_syntax_error("def b(a, *) ->(*) {c(1, *)} end", /anonymous rest parameter is also used/) + assert_syntax_error("def b(*) ->(a, *) {c(*)} end", /anonymous rest parameter is also used/) assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(*); c(*) end @@ -156,6 +160,9 @@ class TestSyntax < Test::Unit::TestCase def test_anonymous_keyword_rest_forwarding assert_syntax_error("def b; c(**); end", /no anonymous keyword rest parameter/) assert_syntax_error("def b; c(k: 1, **); end", /no anonymous keyword rest parameter/) + assert_syntax_error("def b(**) ->(**) {c(**)} end", /anonymous keyword rest parameter is also used/) + assert_syntax_error("def b(k:, **) ->(**) {c(k: 1, **)} end", /anonymous keyword rest parameter is also used/) + assert_syntax_error("def b(**) ->(k:, **) {c(**)} end", /anonymous keyword rest parameter is also used/) assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(**); c(**) end |