From a850cd1a87bef738c40d9c550fb8823699083f2e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 26 Mar 2024 10:04:54 +0900 Subject: [PATCH] [Bug #20392] Block arguments duplication check at `super` --- parse.y | 3 ++- test/ruby/test_syntax.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 28b03f8cd1..585130c346 100644 --- a/parse.y +++ b/parse.y @@ -2063,8 +2063,9 @@ get_nd_args(struct parser_params *p, NODE *node) return RNODE_FCALL(node)->nd_args; case NODE_QCALL: return RNODE_QCALL(node)->nd_args; - case NODE_VCALL: case NODE_SUPER: + return RNODE_SUPER(node)->nd_args; + case NODE_VCALL: case NODE_ZSUPER: case NODE_YIELD: case NODE_RETURN: diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 42108f955f..371c41fe37 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -2154,6 +2154,13 @@ eom assert_equal 0...1, exp.call(a: 0) end + def test_argument_forwarding_with_super + assert_valid_syntax('def foo(...) super {}; end') + assert_valid_syntax('def foo(...) super() {}; end') + assert_syntax_error('def foo(...) super(...) {}; end', /both block arg and actual block/) + assert_syntax_error('def foo(...) super(1, ...) {}; end', /both block arg and actual block/) + end + def test_class_module_Object_ancestors assert_separately([], <<-RUBY) m = Module.new