From: nobuyoshi nakada Date: 2005-12-26T15:21:00+09:00 Subject: [ruby-dev:28123] Re: 1.8.4 documents? なかだです。 At Sat, 24 Dec 2005 01:55:19 +0900, Koji Arai wrote in [ruby-dev:28105]: > これなんですが、試してみると以下のように 1.8 ではエラーになりますね。 > > def bar; p "bar"; end > alias :"foo" :"bar" > foo > > # => ruby 1.8.4 (2005-12-22) [i686-linux] > -:2: syntax error, unexpected tSTRING_CONTENT > alias :"foo" :"bar" > ^ > -:2: warning: unused literal ignored > # => ruby 1.9.0 (2005-12-10) [i686-linux] > "bar" ChangeLogには載ってませんが、2004-10-30 15:56:17の変更ですね。 バックポートしても問題なさそうに見えますが。 Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.616.2.142 diff -U2 -p -r1.616.2.142 eval.c --- eval.c 20 Dec 2005 13:41:47 -0000 1.616.2.142 +++ eval.c 26 Dec 2005 05:48:52 -0000 @@ -3887,5 +3887,5 @@ rb_eval(self, n) rb_raise(rb_eTypeError, "no class to undef method"); } - rb_undef(ruby_class, node->nd_mid); + rb_undef(ruby_class, rb_to_id(rb_eval(self, node->u2.node))); result = Qnil; break; @@ -3895,10 +3895,11 @@ rb_eval(self, n) rb_raise(rb_eTypeError, "no class to make alias"); } - rb_alias(ruby_class, node->nd_new, node->nd_old); + rb_alias(ruby_class, rb_to_id(rb_eval(self, node->u1.node)), + rb_to_id(rb_eval(self, node->u2.node))); result = Qnil; break; case NODE_VALIAS: - rb_alias_variable(node->nd_new, node->nd_old); + rb_alias_variable(node->u1.id, node->u2.id); result = Qnil; break; Index: gc.c =================================================================== RCS file: /cvs/ruby/src/ruby/gc.c,v retrieving revision 1.168.2.30 diff -U2 -p -r1.168.2.30 gc.c --- gc.c 16 Dec 2005 04:58:51 -0000 1.168.2.30 +++ gc.c 26 Dec 2005 06:14:09 -0000 @@ -815,4 +815,6 @@ gc_mark_children(ptr, lev) case NODE_OP_ASGN_AND: case NODE_MODULE: + case NODE_ALIAS: + case NODE_VALIAS: gc_mark((VALUE)obj->as.node.u1.node, lev); /* fall through */ @@ -829,4 +831,5 @@ gc_mark_children(ptr, lev) case NODE_OPT_N: case NODE_EVSTR: + case NODE_UNDEF: ptr = (VALUE)obj->as.node.u2.node; goto again; @@ -868,9 +871,6 @@ gc_mark_children(ptr, lev) case NODE_NTH_REF: case NODE_BACK_REF: - case NODE_ALIAS: - case NODE_VALIAS: case NODE_REDO: case NODE_RETRY: - case NODE_UNDEF: case NODE_SELF: case NODE_NIL: Index: node.h =================================================================== RCS file: /cvs/ruby/src/ruby/node.h,v retrieving revision 1.50.2.4 diff -U2 -p -r1.50.2.4 node.h --- node.h 8 Oct 2005 09:57:12 -0000 1.50.2.4 +++ node.h 26 Dec 2005 06:14:09 -0000 @@ -210,7 +210,4 @@ typedef struct RNode { #define nd_defn u3.node -#define nd_old u1.id -#define nd_new u2.id - #define nd_cfnc u1.cfunc #define nd_argc u2.argc @@ -312,6 +309,6 @@ typedef struct RNode { #define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v)) #define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0) -#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,o,n,0) -#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,o,n,0) +#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0) +#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0) #define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0) #define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(b),(s)) Index: parse.y =================================================================== RCS file: /cvs/ruby/src/ruby/parse.y,v retrieving revision 1.307.2.25 diff -U2 -p -r1.307.2.25 parse.y --- parse.y 19 Dec 2005 14:33:05 -0000 1.307.2.25 +++ parse.y 26 Dec 2005 05:46:30 -0000 @@ -278,7 +278,7 @@ static void top_local_setup(); %type f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg %type assoc_list assocs assoc undef_list backref string_dvar -%type block_var opt_block_var brace_block cmd_brace_block do_block lhs none +%type block_var opt_block_var brace_block cmd_brace_block do_block lhs none fitem %type mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node -%type fitem variable sym symbol operation operation2 operation3 +%type fsym variable sym symbol operation operation2 operation3 %type cname fname op f_rest_arg %type f_norm_arg f_arg @@ -917,8 +917,15 @@ fname : tIDENTIFIER ; -fitem : fname +fsym : fname | symbol ; +fitem : fsym + { + $$ = NEW_LIT(ID2SYM($1)); + } + | dsym + ; + undef_list : fitem { -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦