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

ruby-changes:53252

From: nobu <ko1@a...>
Date: Wed, 31 Oct 2018 11:57:35 +0900 (JST)
Subject: [ruby-changes:53252] nobu:r65467 (trunk): parse.y: last node of NODE_ARRAY

nobu	2018-10-31 11:57:30 +0900 (Wed, 31 Oct 2018)

  New Revision: 65467

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

  Log:
    parse.y: last node of NODE_ARRAY
    
    * parse.y (heredoc_dedent): manage the last node of NODE_ARRAY,
      when concatenating dedented literals.
      [ruby-core:89649] [Bug #15272]

  Modified files:
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 65466)
+++ test/ruby/test_syntax.rb	(revision 65467)
@@ -759,6 +759,10 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L759
     assert_syntax_error('<<~ "#{}"', /unexpected <</)
   end
 
+  def test_dedented_heredoc_concatenation
+    assert_equal("\n0\n1", eval("<<~0 '1'\n \n0\#{}\n0"))
+  end
+
   def test_lineno_operation_brace_block
     expected = __LINE__ + 1
     actual = caller_lineno\
Index: parse.y
===================================================================
--- parse.y	(revision 65466)
+++ parse.y	(revision 65467)
@@ -6134,12 +6134,14 @@ heredoc_dedent(struct parser_params *p, https://github.com/ruby/ruby/blob/trunk/parse.y#L6134
 	    return 0;
 	}
 	else {
+	    NODE *end = node->nd_end;
 	    node = prev_node->nd_next = node->nd_next;
 	    if (!node) {
 		if (nd_type(prev_node) == NODE_DSTR)
 		    nd_set_type(prev_node, NODE_STR);
 		break;
 	    }
+	    node->nd_end = end;
 	    goto next_str;
 	}
 

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

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