diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-16 12:16:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-16 12:16:59 +0000 |
commit | c8348d0cfa13471e190a412fb2e0b8177bd90941 (patch) | |
tree | 96e0c89ade172375372a6ddebb58158c201b6750 | |
parent | c12af76763a1bff53ed77bc4d236f441d8679880 (diff) | |
download | ruby-c8348d0cfa13471e190a412fb2e0b8177bd90941.tar.gz |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | parse.y | 1 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 14 |
3 files changed, 20 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Sat Jan 16 21:16:21 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@it.aoyama.ac.jp> * enc/unicode.c: Artificial mapping to test buffer expansion code. @@ -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 |