diff --git a/ChangeLog b/ChangeLog index 920fa1e608..91d706a819 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Fri Aug 5 00:08:44 2005 Nobuyoshi Nakada +Fri Aug 5 00:18:19 2005 Nobuyoshi Nakada * enumerator.c (Init_Enumerator): provided features should have extensions. @@ -9,6 +9,11 @@ Fri Aug 5 00:08:44 2005 Nobuyoshi Nakada * eval.c (search_required): ruby library should be prior to statically linked extentions. fixed: [ruby-dev:26711] + * eval.c (formal_assign): returns position of rest arguments variable. + + * parse.y (f_rest_arg): use anonymous variable for rest arguments. + fixed: [ruby-dev:26647] + Thu Aug 4 20:03:18 2005 Tadashi Saito * numeric.c (Init_Numeric): do not share implementation among diff --git a/eval.c b/eval.c index 058bbc63d7..9811c71d95 100644 --- a/eval.c +++ b/eval.c @@ -1105,7 +1105,7 @@ static VALUE module_setup _((VALUE,NODE*)); static VALUE massign _((VALUE,NODE*,VALUE,int)); static void assign _((VALUE,NODE*,VALUE,int)); -static void formal_assign _((VALUE, NODE*, int, VALUE*, VALUE*)); +static int formal_assign _((VALUE, NODE*, int, VALUE*, VALUE*)); typedef struct event_hook { rb_event_hook_func_t func; @@ -5715,7 +5715,7 @@ call_cfunc(func, recv, len, argc, argv) return Qnil; /* not reached */ } -static void +static int formal_assign(recv, node, argc, argv, local_vars) VALUE recv; NODE *node; @@ -5766,13 +5766,14 @@ formal_assign(recv, node, argc, argv, local_vars) while (opt && argc) { assign(recv, opt->nd_head, *argv, 1); argv++; argc--; + ++i; opt = opt->nd_next; } if (opt) { rb_eval(recv, opt); } } - if (RTEST(node->nd_rest)) { + if (node->nd_rest) { VALUE v; if (argc > 0) @@ -5780,7 +5781,9 @@ formal_assign(recv, node, argc, argv, local_vars) else v = rb_ary_new2(0); assign(recv, node->nd_rest, v, 1); + if (argc > 0) return -i - 1; } + return i; } static VALUE @@ -5923,10 +5926,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper) body = body->nd_next; } if (node) { - formal_assign(recv, node, argc, argv, local_vars); - if (RTEST(node->nd_rest)) { - ruby_frame->argc = -(ruby_frame->argc - argc)-1; - } + ruby_frame->argc = formal_assign(recv, node, argc, argv, local_vars); } if (event_hooks) { diff --git a/parse.y b/parse.y index 8dcdf0646d..e4c419ea61 100644 --- a/parse.y +++ b/parse.y @@ -4169,7 +4169,12 @@ f_rest_arg : restarg_mark tIDENTIFIER | restarg_mark { /*%%%*/ - $$ = (NODE*)Qnil; + if (dyna_in_block()) { + $$ = NEW_DASGN_CURR(internal_id(), 0); + } + else { + $$ = NEW_NODE(NODE_LASGN,0,0,local_append(0)); + } /*% $$ = dispatch1(restparam, Qnil); %*/