[前][次][番号順一覧][スレッド一覧]

ruby-changes:41467

From: nobu <ko1@a...>
Date: Fri, 15 Jan 2016 16:12:16 +0900 (JST)
Subject: [ruby-changes:41467] nobu:r53541 (trunk): parse.y: should not deent concatenated string

nobu	2016-01-15 16:12:46 +0900 (Fri, 15 Jan 2016)

  New Revision: 53541

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53541

  Log:
    parse.y: should not deent concatenated string
    
    * parse.y (string1): reset heredoc indent fore each string leteral
      so that concatenated string would not be dedented.
      [ruby-core:72857] [Bug #11990]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 53540)
+++ test/ruby/test_syntax.rb	(revision 53541)
@@ -580,6 +580,15 @@ e" https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L580
     assert_dedented_heredoc(expect, result)
   end
 
+  def test_dedented_heredoc_with_concatenation
+    bug11990 = '[ruby-core:72857] [Bug #11990] concatenated string should not be dedented'
+    %w[eos "eos" 'eos'].each do |eos|
+      assert_equal("x\n  y",
+                   eval("<<~#{eos} '  y'\n  x\neos\n"),
+                   "#{bug11990} with #{eos}")
+    end
+  end
+
   def test_lineno_after_heredoc
     bug7559 = '[ruby-dev:46737]'
     expected, _, actual = __LINE__, <<eom, __LINE__
Index: parse.y
===================================================================
--- parse.y	(revision 53540)
+++ parse.y	(revision 53541)
@@ -3912,7 +3912,6 @@ strings		: string https://github.com/ruby/ruby/blob/trunk/parse.y#L3912
 			else {
 			    node = evstr2dstr(node);
 			}
-			heredoc_indent = 0;
 			$$ = node;
 		    /*%
 			$$ = $1;
@@ -3935,6 +3934,7 @@ string		: tCHAR https://github.com/ruby/ruby/blob/trunk/parse.y#L3934
 string1		: tSTRING_BEG string_contents tSTRING_END
 		    {
 			heredoc_dedent($2);
+			heredoc_indent = 0;
 		    /*%%%*/
 			$$ = $2;
 		    /*%
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53540)
+++ ChangeLog	(revision 53541)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jan 15 16:12:10 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (string1): reset heredoc indent fore each string leteral
+	  so that concatenated string would not be dedented.
+	  [ruby-core:72857] [Bug #11990]
+
 Fri Jan 15 09:25:07 2016  SHIBATA Hiroshi  <hsbt@r...>
 
 	* common.mk: test-sample was changed to test-basic.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]