From: Tanaka Akira Date: 2005-09-02T17:53:52+09:00 Subject: [ruby-dev:26948] Re: core dump with ripper In article , nobuyoshi nakada writes: > 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); > } > ; 適用して次のように動かすと途中で duplicated argument arg と出てきます がそういうものでしょうか? % ./ruby -v -rripper -e ' class C < Ripper PARSER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; p r; nil end" } SCANNER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; p r; nil end" } end C.new("def m(a, b) end").parse' ruby 1.9.0 (2005-09-01) [i686-linux] /tmp/r/lib/ruby/1.9/ripper/core.rb:391: warning: method redefined; discarding old on_do_block [:kw, "def"] [:sp, " "] [:ident, "m"] [:lparen, "("] [:ident, "a"] [:comma, ","] [:sp, " "] [:ident, "b"] [:rparen, ")"] [:parse_error, "duplicated argument arg"] [:params, [nil, nil], nil, nil, nil] [:paren, nil] [:sp, " "] [:kw, "end"] [:void_stmt] [:stmts_new] [:stmts_add, nil, nil] [:bodystmt, nil, nil, nil, nil] [:def, nil, nil, nil] [:stmts_new] [:stmts_add, nil, nil] [:program, nil] -- [田中 哲][たなか あきら][Tanaka Akira]