diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-26 00:33:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-26 00:33:06 +0000 |
commit | 6c0f395c012583c979f7569374965c0d96be9297 (patch) | |
tree | 3929d0e2ad3c603ae44b673a8a57b6d66d909617 /parse.y | |
parent | e35907a4b711b2571ef24d63caf03d1ef2c1bcb9 (diff) | |
download | ruby-6c0f395c012583c979f7569374965c0d96be9297.tar.gz |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -6234,6 +6234,7 @@ parser_heredoc_identifier(struct parser_params *parser) int token = tSTRING_BEG; long len; int newline = 0; + int indent = 0; if (c == '-') { c = nextc(); @@ -6242,8 +6243,7 @@ parser_heredoc_identifier(struct parser_params *parser) else if (c == '~') { c = nextc(); func = STR_FUNC_INDENT; - heredoc_indent = INT_MAX; - heredoc_line_indent = 0; + indent = INT_MAX; } switch (c) { case '\'': @@ -6282,7 +6282,7 @@ parser_heredoc_identifier(struct parser_params *parser) if (!parser_is_identchar()) { pushback(c); if (func & STR_FUNC_INDENT) { - pushback(heredoc_indent > 0 ? '~' : '-'); + pushback(indent > 0 ? '~' : '-'); } return 0; } @@ -6305,6 +6305,8 @@ parser_heredoc_identifier(struct parser_params *parser) lex_lastline); /* nd_orig */ parser_set_line(lex_strterm, ruby_sourceline); ripper_flush(parser); + heredoc_indent = indent; + heredoc_line_indent = 0; return token; } |