* vm_insnhelper.c (vm_invoke_block): we should not expect ci->argc is
stable after invoking a block. [Bug #11451] * test/ruby/test_yield.rb: add a test. This test script is given by Alex Dowad. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e5ffa438f2
commit
416aa45918
@ -1,3 +1,11 @@
|
|||||||
|
Fri Aug 21 17:32:42 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_invoke_block): we should not expect ci->argc is
|
||||||
|
stable after invoking a block. [Bug #11451]
|
||||||
|
|
||||||
|
* test/ruby/test_yield.rb: add a test. This test script is given by
|
||||||
|
Alex Dowad.
|
||||||
|
|
||||||
Fri Aug 21 06:35:50 2015 Aaron Patterson <tenderlove@ruby-lang.org>
|
Fri Aug 21 06:35:50 2015 Aaron Patterson <tenderlove@ruby-lang.org>
|
||||||
|
|
||||||
* test/openssl/test_ssl_session.rb: Fix tests so that they take in to
|
* test/openssl/test_ssl_session.rb: Fix tests so that they take in to
|
||||||
|
@ -401,4 +401,28 @@ class TestRubyYieldGen < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_equal [m, nil], y.s(m){|a,b|[a,b]}
|
assert_equal [m, nil], y.s(m){|a,b|[a,b]}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_block_cached_argc
|
||||||
|
# [Bug #11451]
|
||||||
|
assert_separately([], <<-"end;")
|
||||||
|
class Yielder
|
||||||
|
def each
|
||||||
|
yield :x, :y, :z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class Getter1
|
||||||
|
include Enumerable
|
||||||
|
def each(&block)
|
||||||
|
Yielder.new.each(&block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class Getter2
|
||||||
|
include Enumerable
|
||||||
|
def each
|
||||||
|
Yielder.new.each { |a, b, c, d| yield(a) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Getter1.new.map{Getter2.new.each{|x|}}
|
||||||
|
end;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -2336,10 +2336,11 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VALUE val;
|
VALUE val;
|
||||||
|
int argc = ci->argc;
|
||||||
CALLER_SETUP_ARG(th->cfp, ci);
|
CALLER_SETUP_ARG(th->cfp, ci);
|
||||||
val = vm_yield_with_cfunc(th, block, block->self,
|
|
||||||
ci->argc, STACK_ADDR_FROM_TOP(ci->argc), 0);
|
val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc), 0);
|
||||||
POPN(ci->argc); /* TODO: should put before C/yield? */
|
POPN(argc); /* TODO: should put before C/yield? */
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user