summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-24 08:59:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-24 08:59:34 +0000
commit5f80d051a685021ed423c9ab8c7816626a587078 (patch)
treeecbdca5ab67c8264e3c1b1126b01edb7a11623df /eval.c
parent170aaabe4b118d2d2cc85e138d79f11c86166b4e (diff)
* eval.c (rb_yield_0): show yielded block position not only yielding
point. [ruby-dev:20441] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/eval.c b/eval.c
index 4d19b89..0468d37 100644
--- a/eval.c
+++ b/eval.c
@@ -2350,7 +2350,6 @@ rb_Array(val)
VALUE val;
{
VALUE tmp = rb_check_array_type(val);
- ID to_a;
if (NIL_P(tmp)) {
/* hack to avoid invoke Object#to_a */
@@ -4080,21 +4079,26 @@ rb_yield_0(val, self, klass, pcall, avalue)
massign(self, block->var, val, pcall);
}
else {
+ int len = 0;
if (avalue) {
- if (RARRAY(val)->len == 0) {
- goto zero_arg;
- }
- if (RARRAY(val)->len == 1) {
+ len = RARRAY(val)->len;
+ if (len == 1) {
val = RARRAY(val)->ptr[0];
}
else {
- rb_warn("multiple values for a block parameter (%d for 1)", RARRAY(val)->len);
+ goto mult_values;
}
}
else if (val == Qundef) {
- zero_arg:
- rb_warn("multiple values for a block parameter (0 for 1)");
val = Qnil;
+ mult_values:
+ {
+ NODE *curr = ruby_current_node;
+ ruby_current_node = block->var;
+ rb_warn("multiple values for a block parameter (%d for 1)\n\tfrom %s:%d",
+ len, curr->nd_file, nd_line(curr));
+ ruby_current_node = curr;
+ }
}
assign(self, block->var, val, pcall);
}