[parser] Throw syntax error for %Foo(...spread)

Bug: chromium:806200
Change-Id: If76a8cb5b988321d38d170dfba7c1fc5354e2667
Reviewed-on: https://chromium-review.googlesource.com/888922
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50922}
This commit is contained in:
Leszek Swirski 2018-01-26 14:52:35 +00:00 committed by Commit Bot
parent 095e62bfcd
commit 3249b162bd
3 changed files with 14 additions and 1 deletions

View File

@ -598,6 +598,7 @@ class ErrorUtils : public AllStatic {
T(IllegalLanguageModeDirective, \
"Illegal '%' directive in function with non-simple parameter list") \
T(IllegalReturn, "Illegal return statement") \
T(IntrinsicWithSpread, "Intrinsic calls do not support spread arguments") \
T(InvalidRestBindingPattern, \
"`...` must be followed by an identifier in declaration contexts") \
T(InvalidRestAssignmentPattern, \

View File

@ -4809,7 +4809,12 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseV8Intrinsic(
ExpressionClassifier classifier(this);
ExpressionListT args = ParseArguments(&spread_pos, CHECK_OK);
DCHECK(!spread_pos.IsValid());
if (spread_pos.IsValid()) {
*ok = false;
ReportMessageAt(spread_pos, MessageTemplate::kIntrinsicWithSpread,
kSyntaxError);
return impl()->NullExpression();
}
return impl()->NewV8Intrinsic(name, args, pos, ok);
}

View File

@ -0,0 +1,7 @@
// 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.
// Flags: --allow-natives-syntax
assertThrows("%Foo(...spread)", SyntaxError);