diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-02 23:21:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-02 23:21:34 +0000 |
commit | 3d2758cb352b66936dc6f55ba395dabc16f6a29f (patch) | |
tree | a13ae4d521d15be815066672005149307920407c | |
parent | 159908e17dc8219919dae194f00c0d6bf45edad9 (diff) | |
download | ruby-3d2758cb352b66936dc6f55ba395dabc16f6a29f.tar.gz |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/ripper/lib/ripper/lexer.rb | 2 | ||||
-rw-r--r-- | test/ripper/test_scanner_events.rb | 6 |
3 files changed, 13 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Wed Feb 3 08:21:32 2016 Seiei Miyagi <hanachin@gmail.com> + + * 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@ruby-lang.org> * re.c (rb_reg_prepare_enc): use already compiled US-ASCII regexp diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb index bb12ee5650..69526340a7 100644 --- a/ext/ripper/lib/ripper/lexer.rb +++ b/ext/ripper/lib/ripper/lexer.rb @@ -66,7 +66,7 @@ class Ripper 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 diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index ab52392eb1..1b7b56ebfe 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -103,6 +103,12 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase [[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 |