diff --git a/ChangeLog b/ChangeLog index 5aeb27a079..3ac70d46dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jan 16 21:16:21 2016 Nobuyoshi Nakada + + * parse.y (xstring): reset heredoc indent after dedenting, + so that following string literal would not be dedented. + [ruby-core:72857] [Bug #11990] + Sat Jan 16 17:24:24 2016 Martin Duerst * enc/unicode.c: Artificial mapping to test buffer expansion code. diff --git a/parse.y b/parse.y index cddd97114b..57cd313cc5 100644 --- a/parse.y +++ b/parse.y @@ -3950,6 +3950,7 @@ xstring : tXSTRING_BEG xstring_contents tSTRING_END /*% %*/ heredoc_dedent($2); + heredoc_indent = 0; /*%%%*/ if (!node) { node = NEW_XSTR(STR_NEW0()); diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index a81e489222..b7f001e2f0 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -2,6 +2,14 @@ require 'test/unit' class TestSyntax < Test::Unit::TestCase + using Module.new { + refine(Object) do + def `(s) #` + s + end + end + } + def assert_syntax_files(test) srcdir = File.expand_path("../../..", __FILE__) srcdir = File.join(srcdir, test) @@ -493,7 +501,7 @@ e" end def assert_dedented_heredoc(expect, result, mesg = "") - %w[eos "eos" 'eos'].each do |eos| + %w[eos "eos" 'eos' `eos`].each do |eos| assert_equal(eval("<<-#{eos}\n#{expect}eos\n"), eval("<<~#{eos}\n#{result}eos\n"), message(mesg) {"with #{eos}"}) @@ -587,6 +595,10 @@ e" eval("<<~#{eos} ' y'\n x\neos\n"), "#{bug11990} with #{eos}") end + %w[eos "eos" 'eos' `eos`].each do |eos| + _, expect = eval("[<<~#{eos}, ' x']\n"" y\n""eos\n") + assert_equal(' x', expect, bug11990) + end end def test_lineno_after_heredoc