ruby-changes:41648
From: nobu <ko1@a...>
Date: Wed, 3 Feb 2016 08:21:39 +0900 (JST)
Subject: [ruby-changes:41648] nobu:r53722 (trunk): Fix Ripper.lex error in dedenting squiggly heredoc
nobu 2016-02-03 08:21:34 +0900 (Wed, 03 Feb 2016) New Revision: 53722 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53722 Log: Fix Ripper.lex error in dedenting squiggly heredoc * ext/ripper/lib/ripper/lexer.rb (on_heredoc_dedent): Fix Ripper.lex error in dedenting squiggly heredoc. heredoc tree is also an array of Elem in the outer tree. [Fix GH-1234] Modified files: trunk/ChangeLog trunk/ext/ripper/lib/ripper/lexer.rb trunk/test/ripper/test_scanner_events.rb Index: ext/ripper/lib/ripper/lexer.rb =================================================================== --- ext/ripper/lib/ripper/lexer.rb (revision 53721) +++ ext/ripper/lib/ripper/lexer.rb (revision 53722) @@ -66,7 +66,7 @@ class Ripper https://github.com/ruby/ruby/blob/trunk/ext/ripper/lib/ripper/lexer.rb#L66 private def on_heredoc_dedent(v, w) - @buf.each do |e| + @buf.last.each do |e| if e.event == :on_tstring_content if (n = dedent_string(e.tok, w)) > 0 e.pos[1] += n Index: ChangeLog =================================================================== --- ChangeLog (revision 53721) +++ ChangeLog (revision 53722) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Feb 3 08:21:32 2016 Seiei Miyagi <hanachin@g...> + + * ext/ripper/lib/ripper/lexer.rb (on_heredoc_dedent): Fix + Ripper.lex error in dedenting squiggly heredoc. heredoc tree is + also an array of Elem in the outer tree. [Fix GH-1234] + Wed Feb 3 02:33:39 2016 NARUSE, Yui <naruse@r...> * re.c (rb_reg_prepare_enc): use already compiled US-ASCII regexp Index: test/ripper/test_scanner_events.rb =================================================================== --- test/ripper/test_scanner_events.rb (revision 53721) +++ test/ripper/test_scanner_events.rb (revision 53722) @@ -103,6 +103,12 @@ class TestRipper::ScannerEvents < Test:: https://github.com/ruby/ruby/blob/trunk/test/ripper/test_scanner_events.rb#L103 [[5, 0], :on_imaginary, "5.6ri"], ], Ripper.lex("1r\n2i\n3ri\n4.2r\n5.6ri") + assert_equal [[[1, 0], :on_heredoc_beg, "<<~EOS"], + [[1, 6], :on_nl, "\n"], + [[2, 2], :on_tstring_content, "heredoc\n"], + [[3, 0], :on_heredoc_end, "EOS"] + ], + Ripper.lex("<<~EOS\n heredoc\nEOS") end def test_location -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/