Index: src/parsing/scanner.cc |
diff --git a/src/parsing/scanner.cc b/src/parsing/scanner.cc |
index bfb5e03d68457841d0bb4e72b5632e7b97a77324..21723eb50a5ec4e0e126da79556adba0c793bf67 100644 |
--- a/src/parsing/scanner.cc |
+++ b/src/parsing/scanner.cc |
@@ -948,16 +948,12 @@ bool Scanner::ScanEscape() { |
break; |
} |
- // According to ECMA-262, section 7.8.4, characters not covered by the |
- // above cases should be illegal, but they are commonly handled as |
- // non-escaped characters by JS VMs. |
+ // Other escaped characters are interpreted as their non-escaped version. |
AddLiteralChar(c); |
return true; |
} |
-// Octal escapes of the forms '\0xx' and '\xxx' are not a part of |
-// ECMA-262. Other JS VMs support them. |
template <bool capture_raw> |
uc32 Scanner::ScanOctalEscape(uc32 c, int length) { |
uc32 x = c - '0'; |
@@ -1039,6 +1035,7 @@ Token::Value Scanner::ScanTemplateSpan() { |
// TEMPLATE_TAIL terminates a TemplateLiteral and does not need to be |
// followed by an Expression. |
+ DCHECK(!has_error()); |
Token::Value result = Token::TEMPLATE_SPAN; |
LiteralScope literal(this); |
StartRawLiteral(); |
@@ -1069,8 +1066,16 @@ Token::Value Scanner::ScanTemplateSpan() { |
AddRawLiteralChar('\n'); |
} |
} |
- } else if (!ScanEscape<capture_raw, in_template_literal>()) { |
- return Token::ILLEGAL; |
+ } else { |
+ ScanEscape<capture_raw, in_template_literal>(); |
vogelheim
2017/02/17 16:33:53
In a template w/ two invalid escapes, this would r
bakkot1
2017/02/17 20:42:18
It would. Fixed.
Octal literals actually have the
|
+ if (has_error()) { |
+ // For templates, invalid escape sequence checking is handled in the |
+ // parser. |
+ invalid_template_escape_message_ = scanner_error_; |
+ invalid_template_escape_location_ = scanner_error_location_; |
+ scanner_error_ = MessageTemplate::kNone; |
+ scanner_error_location_ = Location(); |
+ } |
} |
} else if (c < 0) { |
// Unterminated template literal |