aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-26 00:33:06 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-26 00:33:06 +0000
commit96c01b455248598f981d78f7784b5b19e905dc54 (patch)
tree3929d0e2ad3c603ae44b673a8a57b6d66d909617 /parse.y
parent0ee5415d554ccd480fb5be910b0ff4885be7a35a (diff)
downloadruby-96c01b455248598f981d78f7784b5b19e905dc54.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.y8
1 files changed, 5 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 35de2cc848..c89b8afc8e 100644
--- a/parse.y
+++ b/parse.y
@@ -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;
}