mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: fix internal IDs conflict
* parse.y (f_kwrest, new_args_tail_gen): unnamed rest keyword and keywords bits arguments should be unique. since internal IDs depend on the local variable index in the current scope, new ID should be made before popping those vtables. [ruby-core:67157] [Bug #10659] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dd038cb69d
commit
952ed33b13
3 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
|||
Sun Dec 28 13:54:26 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (f_kwrest, new_args_tail_gen): unnamed rest keyword and
|
||||
keywords bits arguments should be unique. since internal IDs
|
||||
depend on the local variable index in the current scope, new ID
|
||||
should be made before popping those vtables.
|
||||
[ruby-core:67157] [Bug #10659]
|
||||
|
||||
Sat Dec 27 20:12:55 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/json/generator/generator.c (JSON_Generator_State_type): add
|
||||
|
|
4
parse.y
4
parse.y
|
@ -4829,6 +4829,7 @@ f_kwrest : kwrest_mark tIDENTIFIER
|
|||
| kwrest_mark
|
||||
{
|
||||
$$ = internal_id();
|
||||
arg_var($$);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -9768,6 +9769,8 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b)
|
|||
kwn = kwn->nd_next;
|
||||
}
|
||||
|
||||
kw_bits = internal_id();
|
||||
if (kr && is_junk_id(kr)) vtable_pop(lvtbl->args, 1);
|
||||
vtable_pop(lvtbl->args, vtable_size(required_kw_vars) + vtable_size(kw_vars) + (b != 0));
|
||||
|
||||
for (i=0; i<vtable_size(required_kw_vars); i++) arg_var(required_kw_vars->tbl[i]);
|
||||
|
@ -9775,7 +9778,6 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b)
|
|||
vtable_free(required_kw_vars);
|
||||
vtable_free(kw_vars);
|
||||
|
||||
kw_bits = internal_id();
|
||||
arg_var(kw_bits);
|
||||
if (kr) arg_var(kr);
|
||||
if (b) arg_var(b);
|
||||
|
|
|
@ -539,4 +539,24 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||
o.foo {raise "unreachable"}
|
||||
}
|
||||
end
|
||||
|
||||
def test_super_with_anon_restkeywords
|
||||
bug10659 = '[ruby-core:67157] [Bug #10659]'
|
||||
|
||||
foo = Class.new do
|
||||
def foo(**h)
|
||||
h
|
||||
end
|
||||
end
|
||||
|
||||
class << (obj = foo.new)
|
||||
def foo(bar: "bar", **)
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
assert_nothing_raised(TypeError, bug10659) {
|
||||
assert_equal({:bar => "bar"}, obj.foo, bug10659)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue