ruby-changes:45990
From: nagachika <ko1@a...>
Date: Wed, 22 Mar 2017 23:26:48 +0900 (JST)
Subject: [ruby-changes:45990] nagachika:r58061 (ruby_2_3): merge revision(s) 56020, 57717: [Backport #13253]
nagachika 2017-03-22 23:26:42 +0900 (Wed, 22 Mar 2017) New Revision: 58061 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58061 Log: merge revision(s) 56020,57717: [Backport #13253] parse.y: heredoc token * parse.y (parser_heredoc_identifier): gather branches by quote char. 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_3/ Modified files: branches/ruby_2_3/parse.y branches/ruby_2_3/test/ruby/test_syntax.rb branches/ruby_2_3/version.h Index: ruby_2_3/parse.y =================================================================== --- ruby_2_3/parse.y (revision 58060) +++ ruby_2_3/parse.y (revision 58061) @@ -6526,7 +6526,9 @@ static int https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L6526 parser_heredoc_identifier(struct parser_params *parser) { int c = nextc(), term, func = 0; + int token = tSTRING_BEG; long len; + int indent = 0; if (c == '-') { c = nextc(); @@ -6535,8 +6537,7 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L6537 else if (c == '~') { c = nextc(); func = STR_FUNC_INDENT; - heredoc_indent = INT_MAX; - heredoc_line_indent = 0; + indent = INT_MAX; } switch (c) { case '\'': @@ -6544,7 +6545,9 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L6545 case '"': func |= str_dquote; goto quoted; case '`': - func |= str_xquote; + token = tXSTRING_BEG; + func |= str_xquote; goto quoted; + quoted: newtok(); tokadd(func); @@ -6562,12 +6565,11 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L6565 if (!parser_is_identchar()) { pushback(c); if (func & STR_FUNC_INDENT) { - pushback(heredoc_indent > 0 ? '~' : '-'); + pushback(indent > 0 ? '~' : '-'); } return 0; } newtok(); - term = '"'; tokadd(func |= str_dquote); do { if (tokadd_mbchar(c) == -1) return 0; @@ -6586,7 +6588,9 @@ parser_heredoc_identifier(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L6588 lex_lastline); /* nd_orig */ nd_set_line(lex_strterm, ruby_sourceline); ripper_flush(parser); - return term == '`' ? tXSTRING_BEG : tSTRING_BEG; + heredoc_indent = indent; + heredoc_line_indent = 0; + return token; } static void Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 58060) +++ ruby_2_3/version.h (revision 58061) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.3" #define RUBY_RELEASE_DATE "2017-03-22" -#define RUBY_PATCHLEVEL 258 +#define RUBY_PATCHLEVEL 259 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_3/test/ruby/test_syntax.rb =================================================================== --- ruby_2_3/test/ruby/test_syntax.rb (revision 58060) +++ ruby_2_3/test/ruby/test_syntax.rb (revision 58061) @@ -622,6 +622,10 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_syntax.rb#L622 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\ Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r56020,57717 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/