summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-22 13:51:44 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-22 13:51:44 +0000
commitbc3ce4588d886202c2422e5dc4010e1c7e83ce38 (patch)
tree0fb542ef19fc4bb047f8a574c8585e68aa72c725
parent56b9d666628541388976eea41ef19484d9ae2926 (diff)
* eval.c (rb_proc_new, YIELD_FUNC_LAMBDA): Add a new nd_state
YIELD_FUNC_LAMBDA which avoids automatic `avalue' conversion for arguments. This fixes a bug where [1,[2,3]].map(&:object_id) fails. * intern.h, object.c: Hide rb_proc_new() from intern.h. It should not be considered an official API function yet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--eval.c15
-rw-r--r--intern.h1
-rw-r--r--object.c2
4 files changed, 23 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 38458917c4..3354a715f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Tue Apr 22 22:43:05 2008 Akinori MUSHA <knu@iDaemons.org>
+
+ * eval.c (rb_proc_new, YIELD_FUNC_LAMBDA): Add a new nd_state
+ YIELD_FUNC_LAMBDA which avoids automatic `avalue' conversion for
+ arguments. This fixes a bug where [1,[2,3]].map(&:object_id)
+ fails.
+
+ * intern.h, object.c: Hide rb_proc_new() from intern.h. It should
+ not be considered an official API function yet.
+
Tue Apr 22 21:24:32 2008 Akinori MUSHA <knu@iDaemons.org>
* eval.c (rb_proc_new): Turn the BLOCK_LAMBDA flag on.
diff --git a/eval.c b/eval.c
index a9eb3d38c1..0b102b97f9 100644
--- a/eval.c
+++ b/eval.c
@@ -1111,6 +1111,7 @@ static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
#define YIELD_PUBLIC_DEF 4
#define YIELD_FUNC_AVALUE 1
#define YIELD_FUNC_SVALUE 2
+#define YIELD_FUNC_LAMBDA 3
static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int,VALUE));
static VALUE module_setup _((VALUE,NODE*));
@@ -5014,12 +5015,18 @@ rb_yield_0(val, self, klass, flags, avalue)
if ((state = EXEC_TAG()) == 0) {
redo:
if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
- if (node->nd_state == YIELD_FUNC_AVALUE) {
+ switch (node->nd_state) {
+ case YIELD_FUNC_LAMBDA:
+ if (!avalue) {
+ val = rb_ary_new3(1, val);
+ }
+ break;
+ case YIELD_FUNC_AVALUE:
if (!avalue) {
val = svalue_to_avalue(val);
}
- }
- else {
+ break;
+ default:
if (avalue) {
val = avalue_to_svalue(val);
}
@@ -9635,7 +9642,7 @@ rb_proc_new(func, val)
VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
Data_Get_Struct(proc, struct BLOCK, data);
- data->body->nd_state = YIELD_FUNC_AVALUE;
+ data->body->nd_state = YIELD_FUNC_LAMBDA;
data->flags |= BLOCK_LAMBDA;
return proc;
}
diff --git a/intern.h b/intern.h
index abf6752311..a676720530 100644
--- a/intern.h
+++ b/intern.h
@@ -194,7 +194,6 @@ void rb_obj_call_init _((VALUE, int, VALUE*));
VALUE rb_class_new_instance _((int, VALUE*, VALUE));
VALUE rb_block_proc _((void));
VALUE rb_f_lambda _((void));
-VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
VALUE rb_proc_call _((VALUE, VALUE));
VALUE rb_obj_method _((VALUE, VALUE));
VALUE rb_protect _((VALUE (*)(VALUE), VALUE, int*));
diff --git a/object.c b/object.c
index 1d38798005..d45934b877 100644
--- a/object.c
+++ b/object.c
@@ -1225,6 +1225,8 @@ sym_call(args, mid)
return rb_apply(obj, (ID)mid, args);
}
+VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
+
/*
* call-seq:
* sym.to_proc