summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/ripper/lib/ripper/lexer.rb2
-rw-r--r--test/ripper/test_scanner_events.rb6
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 47fd57de635..548beaa6ae6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 bb12ee56507..69526340a7f 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 ab52392eb1b..1b7b56ebfeb 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