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

ruby-changes:45839

From: naruse <ko1@a...>
Date: Sun, 12 Mar 2017 23:39:22 +0900 (JST)
Subject: [ruby-changes:45839] naruse:r57912 (ruby_2_4): merge revision(s) 57717: [Backport #13253]

naruse	2017-03-12 23:39:18 +0900 (Sun, 12 Mar 2017)

  New Revision: 57912

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

  Log:
    merge revision(s) 57717: [Backport #13253]
    
    parse.y: indent at invalid identifier
    
    * parse.y (parser_heredoc_identifier): set indent only when valid
      identifier, not to dedent non-existent contents later.
      [ruby-core:79772] [Bug #13253]

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/parse.y
    branches/ruby_2_4/test/ruby/test_syntax.rb
    branches/ruby_2_4/version.h
Index: ruby_2_4/test/ruby/test_syntax.rb
===================================================================
--- ruby_2_4/test/ruby/test_syntax.rb	(revision 57911)
+++ ruby_2_4/test/ruby/test_syntax.rb	(revision 57912)
@@ -656,6 +656,10 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_syntax.rb#L656
     assert_equal(expected, actual, bug7559)
   end
 
+  def test_dedented_heredoc_invalid_identifer
+    assert_syntax_error('<<~ "#{}"', /unexpected <</)
+  end
+
   def test_lineno_operation_brace_block
     expected = __LINE__ + 1
     actual = caller_lineno\
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 57911)
+++ ruby_2_4/version.h	(revision 57912)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
 #define RUBY_RELEASE_DATE "2017-03-12"
-#define RUBY_PATCHLEVEL 68
+#define RUBY_PATCHLEVEL 69
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_4/parse.y
===================================================================
--- ruby_2_4/parse.y	(revision 57911)
+++ ruby_2_4/parse.y	(revision 57912)
@@ -6407,6 +6407,7 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L6407
     int token = tSTRING_BEG;
     long len;
     int newline = 0;
+    int indent = 0;
 
     if (c == '-') {
 	c = nextc();
@@ -6415,8 +6416,7 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L6416
     else if (c == '~') {
 	c = nextc();
 	func = STR_FUNC_INDENT;
-	heredoc_indent = INT_MAX;
-	heredoc_line_indent = 0;
+	indent = INT_MAX;
     }
     switch (c) {
       case '\'':
@@ -6455,7 +6455,7 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L6455
 	if (!parser_is_identchar()) {
 	    pushback(c);
 	    if (func & STR_FUNC_INDENT) {
-		pushback(heredoc_indent > 0 ? '~' : '-');
+		pushback(indent > 0 ? '~' : '-');
 	    }
 	    return 0;
 	}
@@ -6478,6 +6478,8 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L6478
 				  lex_lastline);		/* nd_orig */
     nd_set_line(lex_strterm, ruby_sourceline);
     ripper_flush(parser);
+    heredoc_indent = indent;
+    heredoc_line_indent = 0;
     return token;
 }
 

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57717


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

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