diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-21 08:08:36 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-21 08:08:36 +0000 |
commit | 2ca2a4a43bb018bfd84fccc75e395c1f0e58acc6 (patch) | |
tree | 60b46bd4507018b7c53ba2702d11119699c92779 /eval.c | |
parent | ad5f0fc6ccba716676a40c0a635fd41a8a782d4a (diff) | |
download | ruby-2ca2a4a43bb018bfd84fccc75e395c1f0e58acc6.tar.gz |
* parse.y (block_param): do not use multiple assignment for a sole
block parameter. [ruby-dev:28710]
* eval.c (rb_yield_0): pass a raw yielded value to a sole block
parameter if a value is passed by yield.
* eval.c (proc_invoke): args may not be an array.
* eval.c (rb_proc_yield): pass original value without wrapping
it in an array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -4739,6 +4739,9 @@ rb_yield_0(VALUE val, VALUE self, VALUE klass /* OK */, int flags) massign(self, var, val, pcall); } else { + if (pcall) { + val = RARRAY(val)->ptr[0]; + } assign(self, var, val, pcall); } if (bvar) { @@ -8367,7 +8370,7 @@ proc_invoke(VALUE proc, VALUE args /* OK */, VALUE self, VALUE klass, int call) _block.block_obj = bvar; if (self != Qundef) _block.frame.self = self; if (klass) _block.frame.this_class = klass; - _block.frame.argc = RARRAY(args)->len; + _block.frame.argc = call ? RARRAY(args)->len : 1; _block.frame.flags = ruby_frame->flags; if (_block.frame.argc && (ruby_frame->flags & FRAME_DMETH)) { NEWOBJ(scope, struct SCOPE); @@ -8473,10 +8476,14 @@ rb_proc_call(VALUE proc, VALUE args /* OK */) VALUE rb_proc_yield(int argc, VALUE *argv, VALUE proc) { - if (argc == 1) - return proc_invoke(proc, svalue_to_avalue(argv[0]), Qundef, 0, 0); - else + switch (argc) { + case 0: + return proc_invoke(proc, Qnil, Qundef, 0, 0); + case 1: + return proc_invoke(proc, argv[0], Qundef, 0, 0); + default: return proc_invoke(proc, rb_ary_new4(argc, argv), Qundef, 0, 0); + } } /* :nodoc: */ |