Commit 96cf8476 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Only clear invalid template escape messages if we have them

Change-Id: I9925db0d74ef96bf91ea261f275e37c10908c9ef
Reviewed-on: https://chromium-review.googlesource.com/c/1335695
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57507}
parent 7aac6bc9
......@@ -773,15 +773,14 @@ class ParserBase {
inline bool CheckTemplateEscapes(bool should_throw) {
DCHECK(scanner()->current_token() == Token::TEMPLATE_SPAN ||
scanner()->current_token() == Token::TEMPLATE_TAIL);
if (!scanner()->has_invalid_template_escape()) {
return true;
}
if (!scanner()->has_invalid_template_escape()) return true;
// Handle error case(s)
if (should_throw) {
impl()->ReportMessageAt(scanner()->invalid_template_escape_location(),
scanner()->invalid_template_escape_message());
}
scanner()->clear_invalid_template_escape_message();
return should_throw;
}
......
......@@ -501,8 +501,6 @@ V8_INLINE Token::Value Scanner::ScanSingleToken() {
void Scanner::Scan(TokenDesc* next_desc) {
DCHECK_EQ(next_desc, &next());
next_desc->invalid_template_escape_message = MessageTemplate::kNone;
next_desc->token = ScanSingleToken();
DCHECK_IMPLIES(has_parser_error(), next_desc->token == Token::ILLEGAL);
next_desc->location.end_pos = source_pos();
......
......@@ -296,6 +296,12 @@ class Scanner {
DCHECK(has_invalid_template_escape());
return current().invalid_template_escape_message;
}
void clear_invalid_template_escape_message() {
DCHECK(has_invalid_template_escape());
current_->invalid_template_escape_message = MessageTemplate::kNone;
}
Location invalid_template_escape_location() const {
DCHECK(has_invalid_template_escape());
return current().invalid_template_escape_location;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment