[parser] Cook invalid template literals if we've thrown

Otherwise we may look into the invalid string literal later.

Bug: chromium:903527
Change-Id: Ieeb3807bd05e532224e04a59878f5dac24e19579
Reviewed-on: https://chromium-review.googlesource.com/c/1329691
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57423}
This commit is contained in:
Toon Verwaest 2018-11-12 09:58:47 +01:00 committed by Commit Bot
parent c357d22cfd
commit 65ab5bb669
3 changed files with 7 additions and 1 deletions

View File

@ -3084,6 +3084,7 @@ class AstNodeFactory final {
}
Literal* NewStringLiteral(const AstRawString* string, int pos) {
DCHECK_NOT_NULL(string);
return new (zone_) Literal(string, pos);
}

View File

@ -782,7 +782,7 @@ class ParserBase {
impl()->ReportMessageAt(scanner()->invalid_template_escape_location(),
scanner()->invalid_template_escape_message());
}
return false;
return should_throw;
}
void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos);

View File

@ -0,0 +1,5 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
assertThrows("e*!`\\2`", SyntaxError)