aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y11
1 files changed, 9 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index cf05a9c891..daa0fe1f96 100644
--- a/parse.y
+++ b/parse.y
@@ -6434,13 +6434,20 @@ parser_heredoc_identifier(struct parser_params *parser)
while ((c = nextc()) != -1 && c != term) {
if (tokadd_mbchar(c) == -1) return 0;
if (c == '\n') newline = 1;
+ else if (newline) newline = 2;
}
if (c == -1) {
compile_error(PARSER_ARG "unterminated here document identifier");
return 0;
}
- if (newline) {
- rb_warn0("here document identifier contains newline");
+ switch (newline) {
+ case 1:
+ rb_warn0("here document identifier ends with a newline");
+ if (--tokidx > 0 && tokenbuf[tokidx] == '\r') --tokidx;
+ break;
+ case 2:
+ compile_error(PARSER_ARG "here document identifier across newlines, never match");
+ return -1;
}
break;