1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 51651,51655: [Backport #11451]

* 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/branches/ruby_2_2@52717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2015-11-22 15:40:37 +00:00
parent 74eb4cab63
commit ceab943d08
4 changed files with 39 additions and 6 deletions

View file

@ -1,3 +1,11 @@
Mon Nov 23 00:19:51 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.
Thu Nov 19 01:06:07 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (rb_load_internal0): stop separating exits at loading

View file

@ -390,4 +390,28 @@ class TestRubyYieldGen < Test::Unit::TestCase
end
assert_equal [m, nil], y.s(m){|a,b|[a,b]}
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

View file

@ -1,10 +1,10 @@
#define RUBY_VERSION "2.2.4"
#define RUBY_RELEASE_DATE "2015-11-19"
#define RUBY_PATCHLEVEL 193
#define RUBY_RELEASE_DATE "2015-11-23"
#define RUBY_PATCHLEVEL 194
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 11
#define RUBY_RELEASE_DAY 19
#define RUBY_RELEASE_DAY 23
#include "ruby/version.h"

View file

@ -2094,10 +2094,11 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci
}
else {
VALUE val;
int argc;
CALLER_SETUP_ARG(th->cfp, ci);
val = vm_yield_with_cfunc(th, block, block->self, block->klass,
ci->argc, STACK_ADDR_FROM_TOP(ci->argc), 0);
POPN(ci->argc); /* TODO: should put before C/yield? */
argc = ci->argc;
val = vm_yield_with_cfunc(th, block, block->self, block->klass, argc, STACK_ADDR_FROM_TOP(argc), 0);
POPN(argc); /* TODO: should put before C/yield? */
return val;
}
}