diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_proc.rb | 26 | ||||
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | vm_insnhelper.c | 8 |
4 files changed, 38 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Sun Jul 5 08:08:25 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_insnhelper.c (vm_yield_setup_block_args): restores the firs + arg where is overwritten at funcall. [ruby-core:24139] + Fri Jul 3 19:48:40 2009 Tadayoshi Funaba <tadf@dotrb.org> * complex.c: undef-ed shome methods. [ruby-core:24110] diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 83ef8f38dd..89ae569e34 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -673,4 +673,30 @@ class TestProc < Test::Unit::TestCase }.call(1,2,3,4,5) assert_equal([1,2,[3],4,5], r, "[ruby-core:19485]") end + + def test_to_s + assert_match(/^#<Proc:0x\h+@#{ Regexp.quote(__FILE__) }:\d+>$/, proc {}.to_s) + assert_match(/^#<Proc:0x\h+@#{ Regexp.quote(__FILE__) }:\d+ \(lambda\)>$/, lambda {}.to_s) + assert_match(/^#<Proc:0x\h+ \(lambda\)>$/, method(:p).to_proc.to_s) + x = proc {} + x.taint + assert(x.to_s.tainted?) + end + + def source_location_test + __LINE__ + end + + def test_source_location + file, lineno = method(:source_location_test).source_location + assert_match(/^#{ Regexp.quote(__FILE__) }$/, file) + assert_equal(source_location_test - 1, lineno) + end + + def test_splat_without_respond_to + def (obj = Object.new).respond_to?(m); false end + [obj].each do |a, b| + assert_equal([obj, nil], [a, b], '[ruby-core:24139]') + end + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-07-12" -#define RUBY_PATCHLEVEL 217 +#define RUBY_PATCHLEVEL 218 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index ffb36e9a00..6132bd0fa0 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -761,7 +761,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq, int i; int argc = orig_argc; const int m = iseq->argc; - VALUE ary; + VALUE ary, arg0; int opt_pc = 0; th->mark_stack_len = argc; @@ -771,15 +771,19 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq, * => {|a|} => a = [1, 2] * => {|a, b|} => a, b = [1, 2] */ + arg0 = argv[0]; if (!(iseq->arg_simple & 0x02) && /* exclude {|a|} */ (m + iseq->arg_post_len) > 0 && /* this process is meaningful */ - argc == 1 && !NIL_P(ary = rb_check_array_type(argv[0]))) { /* rhs is only an array */ + argc == 1 && !NIL_P(ary = rb_check_array_type(arg0))) { /* rhs is only an array */ th->mark_stack_len = argc = RARRAY_LEN(ary); CHECK_STACK_OVERFLOW(th->cfp, argc); MEMCPY(argv, RARRAY_PTR(ary), VALUE, argc); } + else { + argv[0] = arg0; + } for (i=argc; i<m; i++) { argv[i] = Qnil; |