[ruby-dev:9600] Re: module_eval
From:
nobu.nakada@...
Date:
2000-04-20 17:22:09 UTC
List:
ruby-dev #9600
なかだです。
*a = false; p a # => nil
になります。[false] になりそうに思えるのですが、これって意図し
た動作でしょうか。
Index: eval.c
===================================================================
RCS file: /home/cvs/ruby/eval.c,v
retrieving revision 1.10.2.16
diff -u -2 -p -r1.10.2.16 eval.c
--- eval.c 2000/04/10 05:48:28 1.10.2.16
+++ eval.c 2000/04/20 17:17:56
@@ -3327,32 +3327,26 @@ massign(self, node, val, check)
list = node->nd_head;
- if (val) {
- if (TYPE(val) != T_ARRAY) {
- val = rb_Array(val);
+ if (TYPE(val) != T_ARRAY) {
+ val = rb_Array(val);
+ }
+ len = RARRAY(val)->len;
+ for (i=0; list && i<len; i++) {
+ assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
+ list = list->nd_next;
+ }
+ if (check && list) goto arg_error;
+ if (node->nd_args) {
+ if (node->nd_args == (NODE*)-1) {
+ /* ignore rest args */
}
- len = RARRAY(val)->len;
- for (i=0; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
- list = list->nd_next;
+ else if (!list && i<len) {
+ assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
}
- if (check && list) goto arg_error;
- if (node->nd_args) {
- if (node->nd_args == (NODE*)-1) {
- /* ignore rest args */
- }
- else if (!list && i<len) {
- assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
- }
- else {
- assign(self, node->nd_args, rb_ary_new2(0), check);
- }
+ else {
+ assign(self, node->nd_args, rb_ary_new2(0), check);
}
- else if (check && i<len) goto arg_error;
}
- else if (node->nd_args && node->nd_args != (NODE*)-1) {
- assign(self, node->nd_args, Qnil, check);
- }
+ else if (check && i<len) goto arg_error;
- if (check && list) goto arg_error;
while (list) {
i++;
Index: eval.c
===================================================================
RCS file: /home/cvs/ruby/eval.c,v
retrieving revision 1.40
diff -u -2 -p -r1.40 eval.c
--- eval.c 2000/04/17 15:39:37 1.40
+++ eval.c 2000/04/20 16:59:22
@@ -3429,35 +3429,29 @@ massign(self, node, val, check)
list = node->nd_head;
- if (val) {
- if (TYPE(val) != T_ARRAY) {
- if (NIL_P(val))
- val = rb_ary_new2(0);
- else
- val = rb_ary_new3(1, val);
+ if (TYPE(val) != T_ARRAY) {
+ if (NIL_P(val))
+ val = rb_ary_new2(0);
+ else
+ val = rb_ary_new3(1, val);
+ }
+ len = RARRAY(val)->len;
+ for (i=0; list && i<len; i++) {
+ assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
+ list = list->nd_next;
+ }
+ if (check && list) goto arg_error;
+ if (node->nd_args) {
+ if (node->nd_args == (NODE*)-1) {
+ /* ignore rest args */
}
- len = RARRAY(val)->len;
- for (i=0; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
- list = list->nd_next;
+ else if (!list && i<len) {
+ assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
}
- if (check && list) goto arg_error;
- if (node->nd_args) {
- if (node->nd_args == (NODE*)-1) {
- /* ignore rest args */
- }
- else if (!list && i<len) {
- assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
- }
- else {
- assign(self, node->nd_args, rb_ary_new2(0), check);
- }
+ else {
+ assign(self, node->nd_args, rb_ary_new2(0), check);
}
- else if (check && i<len) goto arg_error;
}
- else if (node->nd_args && node->nd_args != (NODE*)-1) {
- assign(self, node->nd_args, Qnil, check);
- }
+ else if (check && i<len) goto arg_error;
- if (check && list) goto arg_error;
while (list) {
i++;
# なんか安直な修正(^^;
--
そうだ 強気に ちょっと インチキに☆彡
中田 "Bugるくらいがちょうどいいかも;-)" 伸悦