ruby-changes:41481
From: nobu <ko1@a...>
Date: Sat, 16 Jan 2016 21:16:27 +0900 (JST)
Subject: [ruby-changes:41481] nobu:r53555 (trunk): parse.y: should not deent concatenated string
nobu 2016-01-16 21:16:59 +0900 (Sat, 16 Jan 2016) New Revision: 53555 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53555 Log: parse.y: should not deent concatenated string * parse.y (xstring): reset heredoc indent after dedenting, so that following string literal would not be dedented. [ruby-core:72857] [Bug #11990] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_syntax.rb Index: parse.y =================================================================== --- parse.y (revision 53554) +++ parse.y (revision 53555) @@ -3950,6 +3950,7 @@ xstring : tXSTRING_BEG xstring_contents https://github.com/ruby/ruby/blob/trunk/parse.y#L3950 /*% %*/ heredoc_dedent($2); + heredoc_indent = 0; /*%%%*/ if (!node) { node = NEW_XSTR(STR_NEW0()); Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 53554) +++ test/ruby/test_syntax.rb (revision 53555) @@ -2,6 +2,14 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L2 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" https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L501 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" https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L595 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 Index: ChangeLog =================================================================== --- ChangeLog (revision 53554) +++ ChangeLog (revision 53555) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Jan 16 21:16:21 2016 Nobuyoshi Nakada <nobu@r...> + + * 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 <duerst@i...> * enc/unicode.c: Artificial mapping to test buffer expansion code. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/