Ensure super(**kw, &block) calls kw.to_hash before block.to_proc
Similar as previous commit, but handles the super case with explicit arguments.
This commit is contained in:
parent
a950f23078
commit
f64357540e
@ -9229,6 +9229,9 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
|
||||
VALUE vargc = setup_args(iseq, args, RNODE_SUPER(node)->nd_args, &flag, &keywords);
|
||||
CHECK(!NIL_P(vargc));
|
||||
argc = FIX2INT(vargc);
|
||||
if ((flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT) && !(flag & VM_CALL_KW_SPLAT_MUT)) {
|
||||
ADD_INSN(args, node, splatkw);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* NODE_ZSUPER */
|
||||
|
@ -164,6 +164,26 @@ class TestCall < Test::Unit::TestCase
|
||||
assert_equal([:to_a, :to_hash, :to_proc], ary)
|
||||
end
|
||||
|
||||
def test_kwsplat_block_order_super
|
||||
def self.t(splat)
|
||||
o = Object.new
|
||||
ary = []
|
||||
o.define_singleton_method(:to_a) {ary << :to_a; []}
|
||||
o.define_singleton_method(:to_hash) {ary << :to_hash; {}}
|
||||
o.define_singleton_method(:to_proc) {ary << :to_proc; lambda{}}
|
||||
if splat
|
||||
super(*o, **o, &o)
|
||||
else
|
||||
super(**o, &o)
|
||||
end
|
||||
ary
|
||||
end
|
||||
extend Module.new{def t(...) end}
|
||||
|
||||
assert_equal([:to_hash, :to_proc], t(false))
|
||||
assert_equal([:to_a, :to_hash, :to_proc], t(true))
|
||||
end
|
||||
|
||||
OVER_STACK_LEN = (ENV['RUBY_OVER_STACK_LEN'] || 150).to_i # Greater than VM_ARGC_STACK_MAX
|
||||
OVER_STACK_ARGV = OVER_STACK_LEN.times.to_a.freeze
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user