From 65ab5bb669e6b3a93175dfafce3a30f99c96e28e Mon Sep 17 00:00:00 2001 From: Toon Verwaest Date: Mon, 12 Nov 2018 09:58:47 +0100 Subject: [PATCH] [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 Reviewed-by: Igor Sheludko Cr-Commit-Position: refs/heads/master@{#57423} --- src/ast/ast.h | 1 + src/parsing/parser-base.h | 2 +- test/mjsunit/regress/regress-903527.js | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/mjsunit/regress/regress-903527.js diff --git a/src/ast/ast.h b/src/ast/ast.h index 4f4b675c68..4770e0b23c 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -3084,6 +3084,7 @@ class AstNodeFactory final { } Literal* NewStringLiteral(const AstRawString* string, int pos) { + DCHECK_NOT_NULL(string); return new (zone_) Literal(string, pos); } diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h index e1f3dcfab8..34be16bc1b 100644 --- a/src/parsing/parser-base.h +++ b/src/parsing/parser-base.h @@ -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); diff --git a/test/mjsunit/regress/regress-903527.js b/test/mjsunit/regress/regress-903527.js new file mode 100644 index 0000000000..fe56d8c216 --- /dev/null +++ b/test/mjsunit/regress/regress-903527.js @@ -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)