ruby-changes:46432
From: nobu <ko1@a...>
Date: Wed, 3 May 2017 02:48:15 +0900 (JST)
Subject: [ruby-changes:46432] nobu:r58545 (trunk): ripper/lexer.rb: nested indented heredoc
nobu 2017-05-03 02:48:10 +0900 (Wed, 03 May 2017) New Revision: 58545 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58545 Log: ripper/lexer.rb: nested indented heredoc * ext/ripper/lib/ripper/lexer.rb (on_heredoc_dedent): fix for nested indedented here documents, where `Elem`s are nested too. [ruby-core:80977] [Bug #13536] Added files: trunk/test/ripper/test_lexer.rb Modified files: trunk/ext/ripper/lib/ripper/lexer.rb Index: test/ripper/test_lexer.rb =================================================================== --- test/ripper/test_lexer.rb (nonexistent) +++ test/ripper/test_lexer.rb (revision 58545) @@ -0,0 +1,24 @@ https://github.com/ruby/ruby/blob/trunk/test/ripper/test_lexer.rb#L1 +# frozen_string_literal: true +begin + require_relative 'dummyparser' + require 'test/unit' + ripper_test = true + module TestRipper; end +rescue LoadError +end + +class TestRipper::Lexer < Test::Unit::TestCase + def test_nested_dedent_heredoc + bug = '[ruby-core:80977] [Bug #13536]' + str = <<~'E' + <<~"D" + #{ + <<~"B" + this must be a valid ruby + B + } + D + E + assert_equal(str, Ripper.tokenize(str).join(""), bug) + end +end Property changes on: test/ripper/test_lexer.rb ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: ext/ripper/lib/ripper/lexer.rb =================================================================== --- ext/ripper/lib/ripper/lexer.rb (revision 58544) +++ ext/ripper/lib/ripper/lexer.rb (revision 58545) @@ -67,7 +67,7 @@ class Ripper https://github.com/ruby/ruby/blob/trunk/ext/ripper/lib/ripper/lexer.rb#L67 def on_heredoc_dedent(v, w) @buf.last.each do |e| - if e.event == :on_tstring_content + if Elem === e and e.event == :on_tstring_content if (n = dedent_string(e.tok, w)) > 0 e.pos[1] += n end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/