From: nobuyoshi nakada Date: 2005-09-02T16:37:25+09:00 Subject: [ruby-dev:26946] Re: core dump with ripper なかだです。 At Fri, 2 Sep 2005 00:36:09 +0900, Tanaka Akira wrote in [ruby-dev:26942]: > ripper で次のように core を吐くことがあるようです。 > > % ./ruby -rripper -e ' > class C < Ripper > PARSER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; p r; r end" } > SCANNER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; p r; r end" } > end > C.new("def m(a) end").parse' on_identの戻り値をIDとして扱っちゃってるようで。 Index: parse.y =================================================================== RCS file: /cvs/ruby/src/ruby/parse.y,v retrieving revision 1.407 diff -U2 -p -u -r1.407 parse.y --- parse.y 30 Aug 2005 04:27:40 -0000 1.407 +++ parse.y 2 Sep 2005 07:26:21 -0000 @@ -4096,13 +4096,23 @@ f_norm_arg : tCONSTANT f_arg : f_norm_arg { - $$ = rb_ary_new3(1, ID2SYM($1)); + /*%%%*/ + VALUE arg = ID2SYM($1); + /*% + VALUE arg = $1; + %*/ + $$ = rb_ary_new3(1, arg); } | f_arg ',' f_norm_arg { + /*%%%*/ + VALUE arg = ID2SYM($3); + /*% + VALUE arg = $3; + %*/ $$ = $1; - if (rb_ary_includes($$, ID2SYM($3))) { - yyerror("duplicated argument name"); + if (rb_ary_includes($$, arg)) { + yyerror("duplicated argument arg"); } - rb_ary_push($$, ID2SYM($3)); + rb_ary_push($$, arg); } ; -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦