diff options
| author | NARUSE, Yui <nurse@users.noreply.github.com> | 2024-03-14 18:55:52 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-14 09:55:52 +0000 |
| commit | 2a84aaf4a8c8d6d6bbb09416711922532b0033fe (patch) | |
| tree | 65c9cdcaaa405d0921ce62ca7a6f378b9199c2fd | |
| parent | a889304fed63c3206f27d614ab75219271fb4ca9 (diff) | |
Fix test session reuse but expire (#9824) (#10250)
merge revision(s) 596db9c1f486d6609a4e97d82c8c71b54609fb6f: [Backport #20090]
[Feature #19370] Blocks without anonymous parameters should not
affect
---
parse.y | 4 ++--
test/ruby/test_syntax.rb | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
| -rw-r--r-- | parse.y | 4 | ||||
| -rw-r--r-- | test/ruby/test_syntax.rb | 7 |
2 files changed, 9 insertions, 2 deletions
@@ -15017,13 +15017,13 @@ forwarding_arg_check(struct parser_params *p, ID arg, ID all, const char *var) args = p->lvtbl->args; while (vars && !DVARS_TERMINAL_P(vars->prev)) { + conflict |= (vtable_included(args, arg) && !(all && vtable_included(args, all))); vars = vars->prev; args = args->prev; - conflict |= (vtable_included(args, arg) && !(all && vtable_included(args, all))); } bool found = false; - if (vars && vars->prev == DVARS_INHERIT) { + if (vars && vars->prev == DVARS_INHERIT && !found) { found = (rb_local_defined(arg, p->parent_iseq) && !(all && rb_local_defined(all, p->parent_iseq))); } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 33fcc6a1e0..2d4ce59b39 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -77,6 +77,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_valid_syntax("def b(&) ->() {c(&)} end") assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(&); c(&) end @@ -147,6 +148,9 @@ class TestSyntax < Test::Unit::TestCase 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_valid_syntax("def b(*) ->() {c(*)} end") + assert_valid_syntax("def b(a, *) ->() {c(1, *)} end") + assert_valid_syntax("def b(*) ->(a) {c(*)} end") assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(*); c(*) end @@ -163,6 +167,9 @@ class TestSyntax < Test::Unit::TestCase 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_valid_syntax("def b(**) ->() {c(**)} end") + assert_valid_syntax("def b(k:, **) ->() {c(k: 1, **)} end") + assert_valid_syntax("def b(**) ->(k:) {c(**)} end") assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") begin; def b(**); c(**) end |
