Skip to content

Commit

Permalink
[Bug #20392] Block arguments duplication check at super
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Mar 26, 2024
1 parent 3680981 commit a850cd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,13 @@ def obj.bar(*args, **kws, &block)
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
Expand Down

0 comments on commit a850cd1

Please sign in to comment.