From cc479b25ba715099ac721ad9d0b1b4237fa2b9f9 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 26 Dec 2010 02:39:14 +0000 Subject: [PATCH] * parse.y (stmt): missing ripper rule. i.e., `a::B ||= c 1'. http://twitter.com/#!/wannabe53/status/18797576396472321 http://twitter.com/#!/wannabe53/status/18798416150663168 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ parse.y | 6 ++++++ test/ripper/dummyparser.rb | 14 ++++++++------ test/ripper/test_parser_events.rb | 17 +++++++++++++---- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ab8d260a3..a115950fa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Dec 26 11:39:11 2010 Nobuyoshi Nakada + + * parse.y (stmt): missing ripper rule. i.e., `a::B ||= c 1'. + http://twitter.com/#!/wannabe53/status/18797576396472321 + http://twitter.com/#!/wannabe53/status/18798416150663168 + Sun Dec 26 11:15:50 2010 Nobuyoshi Nakada * test/with_different_ofs.rb (DifferentOFS): should not affect diff --git a/parse.y b/parse.y index 0c80c87ccc..f0b7358a99 100644 --- a/parse.y +++ b/parse.y @@ -1159,8 +1159,14 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem } | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call { + /*%%%*/ yyerror("constant re-assignment"); $$ = 0; + /*% + $$ = dispatch2(const_path_field, $1, $3); + $$ = dispatch3(opassign, $$, $4, $5); + $$ = dispatch1(assign_error, $$); + %*/ } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call { diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb index ffc1f78ac6..07a7eda023 100644 --- a/test/ripper/dummyparser.rb +++ b/test/ripper/dummyparser.rb @@ -10,7 +10,7 @@ class Node @children = nodes end - attr_reader :children + attr_reader :name, :children def to_s "#{@name}(#{Node.trim_nil(@children).map {|n| n.to_s }.join(',')})" @@ -47,12 +47,14 @@ class NodeList end class DummyParser < Ripper - def hook(name) + def hook(*names) class << self; self; end.class_eval do - define_method(name) do |*a, &b| - result = super(*a, &b) - yield(*a) - result + names.each do |name| + define_method(name) do |*a, &b| + result = super(*a, &b) + yield(name, *a) + result + end end end self diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index e269e271d4..7cf56546ca 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -20,7 +20,7 @@ class TestRipper::ParserEvents < Test::Unit::TestCase def parse(str, nm = nil, &bl) dp = DummyParser.new(str) - dp.hook(nm, &bl) if nm + dp.hook(*nm, &bl) if nm dp.parse.to_s end @@ -347,10 +347,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_equal true, thru_heredoc_beg assert_match(/string_content\(\),heredoc\n/, tree, bug1921) heredoc = nil - parse("<