Commit 356b4602 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Revert "Reland "Let all early errors be SyntaxErrors.""

This reverts commit 89d93e38.

Reason for revert: Breaks layout tests: https://ci.chromium.org/p/v8/builders/ci/V8-Blink%20Linux%2064/32929

Original change's description:
> Reland "Let all early errors be SyntaxErrors."
> 
> This is a reland of 99fd5b9b which includes a missed update to
> test/test262/test262.status.
> 
> Implement the spec change from the following TC39 PR:
> https://github.com/tc39/ecma262/pull/1527
> 
> Bug: v8:9326
> Change-Id: Ie3aac60db550e90fb648fc30886a05419fa41afe
> TBR: adamk@chromium.org
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682989
> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62500}

TBR=adamk@chromium.org,gsathya@chromium.org,verwaest@chromium.org,rkirsling@gmail.com

Change-Id: Ia56dcda6780a2b1249749e1e7978b35b5e33fbcf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9326
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687678Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62509}
parent e937bc5e
......@@ -162,7 +162,6 @@ Rob Wu <rob@robwu.nl>
Robert Meijer <robert.s.meijer@gmail.com>
Robert Mustacchi <rm@fingolfin.org>
Robert Nagy <robert.nagy@gmail.com>
Ross Kirsling <rkirsling@gmail.com>
Ruben Bridgewater <ruben@bridgewater.de>
Ryan Dahl <ry@tinyclouds.org>
Sakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>
......
......@@ -182,7 +182,7 @@ deps = {
'v8/test/mozilla/data':
Var('chromium_url') + '/v8/deps/third_party/mozilla-tests.git' + '@' + 'f6c578a10ea707b1a8ab0b88943fe5115ce2b9be',
'v8/test/test262/data':
Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '079b004ac418db8ddcd9134d7cf36b0f5c4a6110',
Var('chromium_url') + '/external/github.com/tc39/test262.git' + '@' + '49eee8bf9d69e3e137e9a196f6e0906a7c6a2cd4',
'v8/test/test262/harness':
Var('chromium_url') + '/external/github.com/test262-utils/test262-harness-py.git' + '@' + '4555345a943d0c99a9461182705543fb171dda4b',
'v8/third_party/qemu-linux-x64': {
......
......@@ -2469,7 +2469,8 @@ bool ClassScope::ResolvePrivateNames(ParseInfo* info) {
Scanner::Location loc = proxy->location();
info->pending_error_handler()->ReportMessageAt(
loc.beg_pos, loc.end_pos,
MessageTemplate::kInvalidPrivateFieldResolution, proxy->raw_name());
MessageTemplate::kInvalidPrivateFieldResolution, proxy->raw_name(),
kSyntaxError);
return false;
} else {
var->set_is_used();
......
......@@ -1170,6 +1170,8 @@ enum MaybeAssignedFlag : uint8_t { kNotAssigned, kMaybeAssigned };
enum RequiresBrandCheckFlag : uint8_t { kNoBrandCheck, kRequiresBrandCheck };
enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 };
enum class InterpreterPushArgsMode : unsigned {
kArrayFunction,
kWithFinalSpread,
......
......@@ -437,7 +437,8 @@ class ExpressionParsingScope : public ExpressionScope<Types> {
}
this->mark_verified();
return this->parser()->RewriteInvalidReferenceExpression(
expression, beg_pos, end_pos, MessageTemplate::kInvalidLhsInFor);
expression, beg_pos, end_pos, MessageTemplate::kInvalidLhsInFor,
kSyntaxError);
}
void RecordExpressionError(const Scanner::Location& loc,
......
......@@ -785,7 +785,7 @@ class ParserBase {
if (scanner()->current_token() == Token::AWAIT && !is_async_function()) {
ReportMessageAt(scanner()->location(),
MessageTemplate::kAwaitNotInAsyncFunction);
MessageTemplate::kAwaitNotInAsyncFunction, kSyntaxError);
return;
}
......@@ -935,19 +935,21 @@ class ParserBase {
V8_NOINLINE void ReportMessage(MessageTemplate message) {
Scanner::Location source_location = scanner()->location();
impl()->ReportMessageAt(source_location, message,
static_cast<const char*>(nullptr));
static_cast<const char*>(nullptr), kSyntaxError);
}
template <typename T>
V8_NOINLINE void ReportMessage(MessageTemplate message, T arg) {
V8_NOINLINE void ReportMessage(MessageTemplate message, T arg,
ParseErrorType error_type = kSyntaxError) {
Scanner::Location source_location = scanner()->location();
impl()->ReportMessageAt(source_location, message, arg);
impl()->ReportMessageAt(source_location, message, arg, error_type);
}
V8_NOINLINE void ReportMessageAt(Scanner::Location location,
MessageTemplate message) {
MessageTemplate message,
ParseErrorType error_type) {
impl()->ReportMessageAt(location, message,
static_cast<const char*>(nullptr));
static_cast<const char*>(nullptr), error_type);
}
V8_NOINLINE void ReportUnexpectedToken(Token::Value token);
......@@ -1216,9 +1218,9 @@ class ParserBase {
// Checks if the expression is a valid reference expression (e.g., on the
// left-hand side of assignments). Although ruled out by ECMA as early errors,
// we allow calls for web compatibility and rewrite them to a runtime throw.
ExpressionT RewriteInvalidReferenceExpression(ExpressionT expression,
int beg_pos, int end_pos,
MessageTemplate message);
ExpressionT RewriteInvalidReferenceExpression(
ExpressionT expression, int beg_pos, int end_pos, MessageTemplate message,
ParseErrorType type = kReferenceError);
bool IsValidReferenceExpression(ExpressionT expression);
......@@ -1570,7 +1572,8 @@ ParserBase<Impl>::ParsePropertyOrPrivatePropertyName() {
if (class_scope == nullptr) {
impl()->ReportMessageAt(Scanner::Location(pos, pos + 1),
MessageTemplate::kInvalidPrivateFieldResolution,
impl()->GetRawNameFromIdentifier(name));
impl()->GetRawNameFromIdentifier(name),
kSyntaxError);
return impl()->FailureExpression();
}
key = impl()->ExpressionFromPrivateName(class_scope, name, pos);
......@@ -2658,11 +2661,13 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() {
impl()->ReportMessageAt(loc,
MessageTemplate::kInvalidDestructuringTarget);
} else {
// Syntax Error if LHS is neither object literal nor an array literal
// Reference Error if LHS is neither object literal nor an array literal
// (Parenthesized literals are
// CoverParenthesizedExpressionAndArrowParameterList).
// #sec-assignment-operators-static-semantics-early-errors
impl()->ReportMessageAt(loc, MessageTemplate::kInvalidLhsInAssignment);
impl()->ReportMessageAt(loc, MessageTemplate::kInvalidLhsInAssignment,
static_cast<const char*>(nullptr),
kReferenceError);
}
}
expression_scope()->ValidateAsPattern(expression, lhs_beg_pos,
......@@ -4301,7 +4306,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
impl()->ReportMessageAt(Scanner::Location(unresolvable->position(),
unresolvable->position() + 1),
MessageTemplate::kInvalidPrivateFieldResolution,
unresolvable->raw_name());
unresolvable->raw_name(), kSyntaxError);
return impl()->FailureExpression();
}
......@@ -4452,14 +4457,15 @@ template <typename Impl>
typename ParserBase<Impl>::ExpressionT
ParserBase<Impl>::RewriteInvalidReferenceExpression(ExpressionT expression,
int beg_pos, int end_pos,
MessageTemplate message) {
MessageTemplate message,
ParseErrorType type) {
DCHECK(!IsValidReferenceExpression(expression));
if (impl()->IsIdentifier(expression)) {
DCHECK(is_strict(language_mode()));
DCHECK(impl()->IsEvalOrArguments(impl()->AsIdentifier(expression)));
ReportMessageAt(Scanner::Location(beg_pos, end_pos),
MessageTemplate::kStrictEvalArguments);
MessageTemplate::kStrictEvalArguments, kSyntaxError);
return impl()->FailureExpression();
}
if (expression->IsCall() && !expression->AsCall()->is_tagged_template()) {
......@@ -4476,7 +4482,7 @@ ParserBase<Impl>::RewriteInvalidReferenceExpression(ExpressionT expression,
ExpressionT error = impl()->NewThrowReferenceError(message, beg_pos);
return factory()->NewProperty(expression, error, beg_pos);
}
ReportMessageAt(Scanner::Location(beg_pos, end_pos), message);
ReportMessageAt(Scanner::Location(beg_pos, end_pos), message, type);
return impl()->FailureExpression();
}
......@@ -4570,7 +4576,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseV8Intrinsic() {
if (has_spread) {
ReportMessageAt(Scanner::Location(pos, position()),
MessageTemplate::kIntrinsicWithSpread);
MessageTemplate::kIntrinsicWithSpread, kSyntaxError);
return impl()->FailureExpression();
}
......
......@@ -696,9 +696,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
// Reporting errors.
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate message, const char* arg = nullptr) {
pending_error_handler()->ReportMessageAt(
source_location.beg_pos, source_location.end_pos, message, arg);
MessageTemplate message, const char* arg = nullptr,
ParseErrorType error_type = kSyntaxError) {
pending_error_handler()->ReportMessageAt(source_location.beg_pos,
source_location.end_pos, message,
arg, error_type);
scanner_.set_parser_error();
}
......@@ -707,9 +709,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
V8_INLINE void ReportUnidentifiableError() { UNREACHABLE(); }
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate message, const AstRawString* arg) {
pending_error_handler()->ReportMessageAt(
source_location.beg_pos, source_location.end_pos, message, arg);
MessageTemplate message, const AstRawString* arg,
ParseErrorType error_type = kSyntaxError) {
pending_error_handler()->ReportMessageAt(source_location.beg_pos,
source_location.end_pos, message,
arg, error_type);
scanner_.set_parser_error();
}
......
......@@ -30,26 +30,26 @@ MessageLocation PendingCompilationErrorHandler::MessageDetails::GetLocation(
return MessageLocation(script, start_position_, end_position_);
}
void PendingCompilationErrorHandler::ReportMessageAt(int start_position,
int end_position,
MessageTemplate message,
const char* arg) {
void PendingCompilationErrorHandler::ReportMessageAt(
int start_position, int end_position, MessageTemplate message,
const char* arg, ParseErrorType error_type) {
if (has_pending_error_) return;
has_pending_error_ = true;
error_details_ =
MessageDetails(start_position, end_position, message, nullptr, arg);
error_type_ = error_type;
}
void PendingCompilationErrorHandler::ReportMessageAt(int start_position,
int end_position,
MessageTemplate message,
const AstRawString* arg) {
void PendingCompilationErrorHandler::ReportMessageAt(
int start_position, int end_position, MessageTemplate message,
const AstRawString* arg, ParseErrorType error_type) {
if (has_pending_error_) return;
has_pending_error_ = true;
error_details_ =
MessageDetails(start_position, end_position, message, arg, nullptr);
error_type_ = error_type;
}
void PendingCompilationErrorHandler::ReportWarningAt(int start_position,
......@@ -97,8 +97,17 @@ void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate,
isolate->debug()->OnCompileError(script);
Factory* factory = isolate->factory();
Handle<Object> error =
factory->NewSyntaxError(error_details_.message(), argument);
Handle<Object> error;
switch (error_type_) {
case kReferenceError:
error = factory->NewReferenceError(error_details_.message(), argument);
break;
case kSyntaxError:
error = factory->NewSyntaxError(error_details_.message(), argument);
break;
default:
UNREACHABLE();
}
if (!error->IsJSObject()) {
isolate->Throw(*error, &location);
......
......@@ -25,13 +25,17 @@ class Script;
class PendingCompilationErrorHandler {
public:
PendingCompilationErrorHandler()
: has_pending_error_(false), stack_overflow_(false) {}
: has_pending_error_(false),
stack_overflow_(false),
error_type_(kSyntaxError) {}
void ReportMessageAt(int start_position, int end_position,
MessageTemplate message, const char* arg = nullptr);
MessageTemplate message, const char* arg = nullptr,
ParseErrorType error_type = kSyntaxError);
void ReportMessageAt(int start_position, int end_position,
MessageTemplate message, const AstRawString* arg);
MessageTemplate message, const AstRawString* arg,
ParseErrorType error_type = kSyntaxError);
void ReportWarningAt(int start_position, int end_position,
MessageTemplate message, const char* arg = nullptr);
......@@ -106,6 +110,7 @@ class PendingCompilationErrorHandler {
bool unidentifiable_error_ = false;
MessageDetails error_details_;
ParseErrorType error_type_;
std::forward_list<MessageDetails> warning_messages_;
......
......@@ -1483,9 +1483,11 @@ class PreParser : public ParserBase<PreParser> {
// Reporting errors.
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate message, const char* arg = nullptr) {
pending_error_handler()->ReportMessageAt(
source_location.beg_pos, source_location.end_pos, message, arg);
MessageTemplate message, const char* arg = nullptr,
ParseErrorType error_type = kSyntaxError) {
pending_error_handler()->ReportMessageAt(source_location.beg_pos,
source_location.end_pos, message,
arg, error_type);
scanner()->set_parser_error();
}
......@@ -1496,14 +1498,17 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE void ReportMessageAt(Scanner::Location source_location,
MessageTemplate message,
const PreParserIdentifier& arg) {
const PreParserIdentifier& arg,
ParseErrorType error_type = kSyntaxError) {
UNREACHABLE();
}
void ReportMessageAt(Scanner::Location source_location,
MessageTemplate message, const AstRawString* arg) {
pending_error_handler()->ReportMessageAt(
source_location.beg_pos, source_location.end_pos, message, arg);
MessageTemplate message, const AstRawString* arg,
ParseErrorType error_type = kSyntaxError) {
pending_error_handler()->ReportMessageAt(source_location.beg_pos,
source_location.end_pos, message,
arg, error_type);
scanner()->set_parser_error();
}
......
*%(basename)s:5: SyntaxError: Invalid left-hand side in assignment
*%(basename)s:5: ReferenceError: Invalid left-hand side in assignment
function f() { new.target = 5 }
^^^^^^^^^^
SyntaxError: Invalid left-hand side in assignment
ReferenceError: Invalid left-hand side in assignment
*%(basename)s:5: SyntaxError: Invalid left-hand side expression in postfix operation
*%(basename)s:5: ReferenceError: Invalid left-hand side expression in postfix operation
function f() { new.target++ }
^^^^^^^^^^
SyntaxError: Invalid left-hand side expression in postfix operation
ReferenceError: Invalid left-hand side expression in postfix operation
*%(basename)s:5: SyntaxError: Invalid left-hand side expression in prefix operation
*%(basename)s:5: ReferenceError: Invalid left-hand side expression in prefix operation
function f() { ++new.target }
^^^^^^^^^^
SyntaxError: Invalid left-hand side expression in prefix operation
ReferenceError: Invalid left-hand side expression in prefix operation
......@@ -401,13 +401,13 @@ function get_new_target() { return new.target; }
(function TestEarlyErrors() {
assertThrows(function() { Function("new.target = 42"); }, SyntaxError);
assertThrows(function() { Function("var foo = 1; new.target = foo = 42"); }, SyntaxError);
assertThrows(function() { Function("var foo = 1; foo = new.target = 42"); }, SyntaxError);
assertThrows(function() { Function("new.target--"); }, SyntaxError);
assertThrows(function() { Function("--new.target"); }, SyntaxError);
assertThrows(function() { Function("(new.target)++"); }, SyntaxError);
assertThrows(function() { Function("++(new.target)"); }, SyntaxError);
assertThrows(function() { Function("new.target = 42"); }, ReferenceError);
assertThrows(function() { Function("var foo = 1; new.target = foo = 42"); }, ReferenceError);
assertThrows(function() { Function("var foo = 1; foo = new.target = 42"); }, ReferenceError);
assertThrows(function() { Function("new.target--"); }, ReferenceError);
assertThrows(function() { Function("--new.target"); }, ReferenceError);
assertThrows(function() { Function("(new.target)++"); }, ReferenceError);
assertThrows(function() { Function("++(new.target)"); }, ReferenceError);
assertThrows(function() { Function("for (new.target of {});"); }, SyntaxError);
})();
......
......@@ -725,20 +725,20 @@ var global = this;
(function testTaggedTemplateInvalidAssignmentTargetStrict() {
"use strict";
function f() {}
assertThrows(() => Function("++f`foo`"), SyntaxError);
assertThrows(() => Function("f`foo`++"), SyntaxError);
assertThrows(() => Function("--f`foo`"), SyntaxError);
assertThrows(() => Function("f`foo`--"), SyntaxError);
assertThrows(() => Function("f`foo` = 1"), SyntaxError);
assertThrows(() => Function("++f`foo`"), ReferenceError);
assertThrows(() => Function("f`foo`++"), ReferenceError);
assertThrows(() => Function("--f`foo`"), ReferenceError);
assertThrows(() => Function("f`foo`--"), ReferenceError);
assertThrows(() => Function("f`foo` = 1"), ReferenceError);
})();
(function testTaggedTemplateInvalidAssignmentTargetSloppy() {
function f() {}
assertThrows(() => Function("++f`foo`"), SyntaxError);
assertThrows(() => Function("f`foo`++"), SyntaxError);
assertThrows(() => Function("--f`foo`"), SyntaxError);
assertThrows(() => Function("f`foo`--"), SyntaxError);
assertThrows(() => Function("f`foo` = 1"), SyntaxError);
assertThrows(() => Function("++f`foo`"), ReferenceError);
assertThrows(() => Function("f`foo`++"), ReferenceError);
assertThrows(() => Function("--f`foo`"), ReferenceError);
assertThrows(() => Function("f`foo`--"), ReferenceError);
assertThrows(() => Function("f`foo` = 1"), ReferenceError);
})();
// Disable eval caching if a tagged template occurs in a nested function
......
......@@ -264,13 +264,13 @@ function TestOverrideMathPow() {
TestOverrideMathPow();
function TestBadAssignmentLHS() {
assertThrows("if (false) { 17 **= 10; }", SyntaxError);
assertThrows("if (false) { '17' **= 10; }", SyntaxError);
assertThrows("if (false) { /17/ **= 10; }", SyntaxError);
assertThrows("if (false) { 17 **= 10; }", ReferenceError);
assertThrows("if (false) { '17' **= 10; }", ReferenceError);
assertThrows("if (false) { /17/ **= 10; }", ReferenceError);
assertThrows("if (false) { ({ valueOf() { return 17; } } **= 10); }",
SyntaxError);
// TODO(caitp): a Call expression as LHS should be an early SyntaxError!
// assertThrows("if (false) { Array() **= 10; }", SyntaxError);
ReferenceError);
// TODO(caitp): a Call expression as LHS should be an early ReferenceError!
// assertThrows("if (false) { Array() **= 10; }", ReferenceError);
assertThrows(() => Array() **= 10, ReferenceError);
}
TestBadAssignmentLHS();
......@@ -29,23 +29,23 @@
// exceptions are delayed until runtime.
// Normal assignments:
assertThrows("12 = 12", SyntaxError);
assertThrows("x++ = 12", SyntaxError);
assertThrows("12 = 12", ReferenceError);
assertThrows("x++ = 12", ReferenceError);
assertThrows("eval('var x') = 12", ReferenceError);
assertThrows("if (false) 12 = 12", SyntaxError);
assertThrows("if (false) 12 = 12", ReferenceError);
assertDoesNotThrow("if (false) eval('var x') = 12");
// Pre- and post-fix operations:
assertThrows("12++", SyntaxError);
assertThrows("12--", SyntaxError);
assertThrows("++12", SyntaxError);
assertThrows("--12", SyntaxError);
assertThrows("12++", ReferenceError);
assertThrows("12--", ReferenceError);
assertThrows("++12", ReferenceError);
assertThrows("--12", ReferenceError);
assertThrows("++(eval('12'))", ReferenceError);
assertThrows("(eval('12'))++", ReferenceError);
assertThrows("if (false) 12++", SyntaxError);
assertThrows("if (false) 12--", SyntaxError);
assertThrows("if (false) ++12", SyntaxError);
assertThrows("if (false) --12", SyntaxError);
assertThrows("if (false) 12++", ReferenceError);
assertThrows("if (false) 12--", ReferenceError);
assertThrows("if (false) ++12", ReferenceError);
assertThrows("if (false) --12", ReferenceError);
assertDoesNotThrow("if (false) ++(eval('12'))");
assertDoesNotThrow("if (false) (eval('12'))++");
......@@ -56,19 +56,19 @@ assertThrows("if (false) for (12 in [1]) print(12);", SyntaxError);
assertDoesNotThrow("if (false) for (eval('0') in [1]) print(12);");
// For:
assertThrows("for (12 = 1;;) print(12);", SyntaxError);
assertThrows("for (12 = 1;;) print(12);", ReferenceError);
assertThrows("for (eval('var x') = 1;;) print(12);", ReferenceError);
assertThrows("if (false) for (12 = 1;;) print(12);", SyntaxError);
assertThrows("if (false) for (12 = 1;;) print(12);", ReferenceError);
assertDoesNotThrow("if (false) for (eval('var x') = 1;;) print(12);");
// Assignments to 'this'.
assertThrows("this = 42", SyntaxError);
assertThrows("function f() { this = 12; }", SyntaxError);
assertThrows("this = 42", ReferenceError);
assertThrows("function f() { this = 12; }", ReferenceError);
assertThrows("for (this in {x:3, y:4, z:5}) ;", SyntaxError);
assertThrows("for (this = 0;;) ;", SyntaxError);
assertThrows("this++", SyntaxError);
assertThrows("++this", SyntaxError);
assertThrows("this--", SyntaxError);
assertThrows("--this", SyntaxError);
assertThrows("if (false) this = 42", SyntaxError);
assertThrows("if (false) this++", SyntaxError);
assertThrows("for (this = 0;;) ;", ReferenceError);
assertThrows("this++", ReferenceError);
assertThrows("++this", ReferenceError);
assertThrows("this--", ReferenceError);
assertThrows("--this", ReferenceError);
assertThrows("if (false) this = 42", ReferenceError);
assertThrows("if (false) this++", ReferenceError);
......@@ -7,7 +7,7 @@
// Parameters can't have parentheses (both patterns and identifiers)
assertThrows("( ({x: 1}) ) => {};", SyntaxError);
assertThrows("( (x) ) => {}", SyntaxError);
assertThrows("( ({x: 1}) = y ) => {}", SyntaxError);
assertThrows("( ({x: 1}) = y ) => {}", ReferenceError);
assertThrows("( (x) = y ) => {}", SyntaxError);
// Declarations can't have parentheses (both patterns and identifiers)
......@@ -21,8 +21,8 @@ assertThrows("var [({x: 1}) = y] = [];", SyntaxError);
assertThrows("var [(x) = y] = [];", SyntaxError);
// Patterns can't have parentheses in assignments either
assertThrows("[({x: 1}) = y] = [];", SyntaxError);
assertThrows("({a,b}) = {a:2,b:3}", SyntaxError);
assertThrows("[({x: 1}) = y] = [];", ReferenceError);
assertThrows("({a,b}) = {a:2,b:3}", ReferenceError);
// Parentheses are fine around identifiers in assignments though, even inside a
// pattern
......
......@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
assertThrows("/*for..in*/for(var [x5, functional] = this = function(id) { return id } in false) var x2, x;", SyntaxError);
assertThrows("/*for..in*/for(var [x5, functional] = this = function(id) { return id } in false) var x2, x;", ReferenceError);
......@@ -10,5 +10,5 @@ try {
f();
assertUnreachable();
} catch(e) {
assertTrue(e instanceof SyntaxError);
assertTrue(e instanceof ReferenceError);
}
......@@ -901,23 +901,23 @@
'language/expressions/dynamic-import/reuse-namespace-object': [SKIP],
'language/expressions/dynamic-import/reuse-namespace-object-from-import': [SKIP],
'language/expressions/dynamic-import/reuse-namespace-object-from-script': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-10-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-11-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-12-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-13-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-14-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-15-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-16-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-17-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-1-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-2-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-3-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-4-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-5-lhs-equals-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-6-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-7-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-8-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-assignmenttargettype-syntax-error-9-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-10-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-11-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-12-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-13-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-14-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-15-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-16-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-17-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-1-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-2-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-3-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-4-update-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-5-lhs-equals-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-6-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-7-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-8-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-9-lhs-assignment-operator-assignment-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-assignment-expr-not-optional': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-no-new-call-expression': [SKIP],
'language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-no-rest-param': [SKIP],
......
......@@ -153,22 +153,22 @@ PASS (function (){'use strict'; function f() { --arguments }}) threw exception S
PASS 'use strict'; function f() { arguments-- } threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS (function (){'use strict'; function f() { arguments-- }}) threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS global.eval('"use strict"; if (0) ++arguments; true;') threw exception SyntaxError: Unexpected eval or arguments in strict mode.
PASS 'use strict'; ++(1, eval) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; ++(1, eval)}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; (1, eval)++ threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; (1, eval)++}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; --(1, eval) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; --(1, eval)}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; (1, eval)-- threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; (1, eval)--}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; function f() { ++(1, arguments) } threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; function f() { ++(1, arguments) }}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; function f() { (1, arguments)++ } threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; function f() { (1, arguments)++ }}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; function f() { --(1, arguments) } threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; function f() { --(1, arguments) }}) threw exception SyntaxError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; function f() { (1, arguments)-- } threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; function f() { (1, arguments)-- }}) threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; ++(1, eval) threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; ++(1, eval)}) threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; (1, eval)++ threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; (1, eval)++}) threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; --(1, eval) threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; --(1, eval)}) threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; (1, eval)-- threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; (1, eval)--}) threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; function f() { ++(1, arguments) } threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; function f() { ++(1, arguments) }}) threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; function f() { (1, arguments)++ } threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; function f() { (1, arguments)++ }}) threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS 'use strict'; function f() { --(1, arguments) } threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS (function (){'use strict'; function f() { --(1, arguments) }}) threw exception ReferenceError: Invalid left-hand side expression in prefix operation.
PASS 'use strict'; function f() { (1, arguments)-- } threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS (function (){'use strict'; function f() { (1, arguments)-- }}) threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
FAIL 'use strict'; undefined; if (0) delete +a.b should throw an exception. Was undefined.
FAIL (function (){'use strict'; undefined; if (0) delete +a.b}) should throw an exception. Was function (){'use strict'; undefined; if (0) delete +a.b}.
FAIL 'use strict'; undefined; if (0) delete ++a.b should throw an exception. Was undefined.
......
......@@ -127,7 +127,7 @@ for (i = 0; i < assignmentOperators.length; ++i) {
testRightAssociativeSame("=", op);
testLowerFirst(op, "+");
shouldThrow("compileAndSerialize('a + b " + op + " c')");
shouldThrow("compileAndSerialize('(a + b) " + op + " c')");
testKeepParentheses("(a + b) " + op + " c");
testKeepParentheses("a + (b " + op + " c)");
}
......@@ -138,10 +138,7 @@ for (i = 0; i < prefixOperators.length; ++i) {
var op = prefixOperators[i] + prefixOperatorSpace[i];
testKeepParentheses("" + op + "a + b");
testOptionalParentheses("(" + op + "a) + b");
if (prefixOperators[i] !== "++" && prefixOperators[i] !== "--")
testKeepParentheses("" + op + "(a + b)");
else
shouldThrow("compileAndSerialize('" + op + "(a + b)')");
testKeepParentheses("" + op + "(a + b)");
testKeepParentheses("!" + op + "a");
testOptionalParentheses("!(" + op + "a)");
}
......@@ -149,11 +146,11 @@ for (i = 0; i < prefixOperators.length; ++i) {
testKeepParentheses("!a++");
testOptionalParentheses("!(a++)");
shouldThrow("compileAndSerialize('(!a)++')");
testKeepParentheses("(!a)++");
testKeepParentheses("!a--");
testOptionalParentheses("!(a--)");
shouldThrow("compileAndSerialize('(!a)--')");
testKeepParentheses("(!a)--");
testKeepParentheses("(-1)[a]");
testKeepParentheses("(-1)[a] = b");
......@@ -208,9 +205,9 @@ testKeepParentheses("(1).a()");
for (i = 0; i < assignmentOperators.length; ++i) {
var op = assignmentOperators[i];
shouldThrow("compileAndSerialize('(-1) " + op + " a')");
shouldThrow("compileAndSerialize('(- 0) " + op + " a')");
shouldThrow("compileAndSerialize('1 " + op + " a')");
testKeepParentheses("(-1) " + op + " a");
testKeepParentheses("(- 0) " + op + " a");
testKeepParentheses("1 " + op + " a");
}
shouldBe("compileAndSerializeLeftmostTest('({ }).x')", "'({ }).x'");
......
......@@ -47,32 +47,32 @@ PASS Invalid: "new -a"
PASS Invalid: "function f() { new -a }"
PASS Valid: "new (-1)"
PASS Valid: "function f() { new (-1) }"
PASS Invalid: "a: b: c: new f(x++)++"
PASS Invalid: "function f() { a: b: c: new f(x++)++ }"
PASS Valid: "a: b: c: new f(x++)++"
PASS Valid: "function f() { a: b: c: new f(x++)++ }"
PASS Valid: "(a)++"
PASS Valid: "function f() { (a)++ }"
PASS Invalid: "(1--).x"
PASS Invalid: "function f() { (1--).x }"
PASS Valid: "(1--).x"
PASS Valid: "function f() { (1--).x }"
PASS Invalid: "a-- ++"
PASS Invalid: "function f() { a-- ++ }"
PASS Invalid: "(a:) --b"
PASS Invalid: "function f() { (a:) --b }"
PASS Invalid: "++ -- ++ a"
PASS Invalid: "function f() { ++ -- ++ a }"
PASS Invalid: "++ new new a ++"
PASS Invalid: "function f() { ++ new new a ++ }"
PASS Valid: "++ -- ++ a"
PASS Valid: "function f() { ++ -- ++ a }"
PASS Valid: "++ new new a ++"
PASS Valid: "function f() { ++ new new a ++ }"
PASS Valid: "delete void 0"
PASS Valid: "function f() { delete void 0 }"
PASS Invalid: "delete the void"
PASS Invalid: "function f() { delete the void }"
PASS Invalid: "(a++"
PASS Invalid: "function f() { (a++ }"
PASS Invalid: "++a--"
PASS Invalid: "function f() { ++a-- }"
PASS Invalid: "++((a))--"
PASS Invalid: "function f() { ++((a))-- }"
PASS Invalid: "(a.x++)++"
PASS Invalid: "function f() { (a.x++)++ }"
PASS Valid: "++a--"
PASS Valid: "function f() { ++a-- }"
PASS Valid: "++((a))--"
PASS Valid: "function f() { ++((a))-- }"
PASS Valid: "(a.x++)++"
PASS Valid: "function f() { (a.x++)++ }"
PASS Invalid: "1: null"
PASS Invalid: "function f() { 1: null }"
PASS Invalid: "+-!~"
......@@ -114,18 +114,18 @@ PASS Invalid: "a in instanceof b.l"
PASS Invalid: "function f() { a in instanceof b.l }"
PASS Valid: "- - true % 5"
PASS Valid: "function f() { - - true % 5 }"
PASS Invalid: "- false = 3"
PASS Invalid: "function f() { - false = 3 }"
PASS Invalid: "a: b: c: (1 + null) = 3"
PASS Invalid: "function f() { a: b: c: (1 + null) = 3 }"
FAIL Invalid: "- false = 3" should throw undefined
FAIL Invalid: "function f() { - false = 3 }" should throw undefined
PASS Valid: "a: b: c: (1 + null) = 3"
PASS Valid: "function f() { a: b: c: (1 + null) = 3 }"
PASS Valid: "a[2] = b.l += c /= 4 * 7 ^ !6"
PASS Valid: "function f() { a[2] = b.l += c /= 4 * 7 ^ !6 }"
PASS Invalid: "a + typeof b += c in d"
PASS Invalid: "function f() { a + typeof b += c in d }"
PASS Invalid: "typeof a &= typeof b"
PASS Invalid: "function f() { typeof a &= typeof b }"
PASS Invalid: "a: ((typeof (a))) >>>= a || b.l && c"
PASS Invalid: "function f() { a: ((typeof (a))) >>>= a || b.l && c }"
FAIL Invalid: "a + typeof b += c in d" should throw undefined
FAIL Invalid: "function f() { a + typeof b += c in d }" should throw undefined
FAIL Invalid: "typeof a &= typeof b" should throw undefined
FAIL Invalid: "function f() { typeof a &= typeof b }" should throw undefined
PASS Valid: "a: ((typeof (a))) >>>= a || b.l && c"
PASS Valid: "function f() { a: ((typeof (a))) >>>= a || b.l && c }"
PASS Valid: "a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g"
PASS Valid: "function f() { a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g }"
PASS Valid: "-void+x['y'].l == x.l != 5 - f[7]"
......@@ -133,8 +133,8 @@ PASS Valid: "function f() { -void+x['y'].l == x.l != 5 - f[7] }"
Function calls (and new with arguments)
PASS Valid: "a()()()"
PASS Valid: "function f() { a()()() }"
PASS Invalid: "s: l: a[2](4 == 6, 5 = 6)(f[4], 6)"
PASS Invalid: "function f() { s: l: a[2](4 == 6, 5 = 6)(f[4], 6) }"
PASS Valid: "s: l: a[2](4 == 6, 5 = 6)(f[4], 6)"
PASS Valid: "function f() { s: l: a[2](4 == 6, 5 = 6)(f[4], 6) }"
PASS Valid: "s: eval(a.apply(), b.call(c[5] - f[7]))"
PASS Valid: "function f() { s: eval(a.apply(), b.call(c[5] - f[7])) }"
PASS Invalid: "a("
......@@ -143,8 +143,8 @@ PASS Invalid: "a(5"
PASS Invalid: "function f() { a(5 }"
PASS Invalid: "a(5,"
PASS Invalid: "function f() { a(5, }"
PASS Valid: "a(5,)"
PASS Valid: "function f() { a(5,) }"
FAIL Invalid: "a(5,)" should throw undefined
FAIL Invalid: "function f() { a(5,) }" should throw undefined
PASS Invalid: "a(5,6"
PASS Invalid: "function f() { a(5,6 }"
PASS Valid: "a(b[7], c <d> e.l, new a() > b)"
......@@ -178,8 +178,8 @@ PASS Invalid: "function () {}"
PASS Invalid: "function f() { function () {} }"
PASS Invalid: "function f(a b) {}"
PASS Invalid: "function f() { function f(a b) {} }"
PASS Valid: "function f(a,) {}"
PASS Valid: "function f() { function f(a,) {} }"
FAIL Invalid: "function f(a,) {}" should throw undefined
FAIL Invalid: "function f() { function f(a,) {} }" should throw undefined
PASS Invalid: "function f(a,"
PASS Invalid: "function f() { function f(a, }"
PASS Invalid: "function f(a, 1) {}"
......@@ -341,8 +341,8 @@ PASS Invalid: "var a = if (b) { c }"
PASS Invalid: "function f() { var a = if (b) { c } }"
PASS Invalid: "var a = var b"
PASS Invalid: "function f() { var a = var b }"
PASS Invalid: "const a = b += c, a, a, a = (b - f())"
PASS Invalid: "function f() { const a = b += c, a, a, a = (b - f()) }"
FAIL Valid: "const a = b += c, a, a, a = (b - f())" should NOT throw
FAIL Valid: "function f() { const a = b += c, a, a, a = (b - f()) }" should NOT throw
PASS Invalid: "var a %= b | 5"
PASS Invalid: "function f() { var a %= b | 5 }"
PASS Invalid: "var (a) = 5"
......@@ -355,10 +355,10 @@ PASS Invalid: "var var = 3"
PASS Invalid: "function f() { var var = 3 }"
PASS Valid: "var varr = 3 in 1"
PASS Valid: "function f() { var varr = 3 in 1 }"
PASS Invalid: "const a, a, a = void 7 - typeof 8, a = 8"
PASS Invalid: "function f() { const a, a, a = void 7 - typeof 8, a = 8 }"
PASS Invalid: "const x_x = 6 /= 7 ? e : f"
PASS Invalid: "function f() { const x_x = 6 /= 7 ? e : f }"
FAIL Valid: "const a, a, a = void 7 - typeof 8, a = 8" should NOT throw
FAIL Valid: "function f() { const a, a, a = void 7 - typeof 8, a = 8 }" should NOT throw
PASS Valid: "const x_x = 6 /= 7 ? e : f"
PASS Valid: "function f() { const x_x = 6 /= 7 ? e : f }"
PASS Invalid: "var a = ?"
PASS Invalid: "function f() { var a = ? }"
PASS Invalid: "const a = *7"
......@@ -452,8 +452,8 @@ PASS Invalid: "for ((a ? b : c) in c) break"
PASS Invalid: "function f() { for ((a ? b : c) in c) break }"
PASS Valid: "for (var a in b in c) break"
PASS Valid: "function f() { for (var a in b in c) break }"
PASS Invalid: "for (var a = 5 += 6 in b) break"
PASS Invalid: "function f() { for (var a = 5 += 6 in b) break }"
PASS Valid: "for (var a = 5 += 6 in b) break"
PASS Valid: "function f() { for (var a = 5 += 6 in b) break }"
PASS Invalid: "for (var a += 5 in b) break"
PASS Invalid: "function f() { for (var a += 5 in b) break }"
PASS Invalid: "for (var a = in b) break"
......@@ -470,8 +470,8 @@ PASS Invalid: "for (var a = (b in c in d) break"
PASS Invalid: "function f() { for (var a = (b in c in d) break }"
PASS Invalid: "for (var (a) in b) { }"
PASS Invalid: "function f() { for (var (a) in b) { } }"
PASS Invalid: "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"
PASS Invalid: "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
PASS Valid: "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"
PASS Valid: "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
try statement
PASS Valid: "try {} finally { c++ }"
PASS Valid: "function f() { try {} finally { c++ } }"
......@@ -582,8 +582,8 @@ PASS Valid: "if (0) obj.foo\u03bb; "
PASS Valid: "function f() { if (0) obj.foo\u03bb; }"
PASS Valid: "if (0) new a(b+c).d = 5"
PASS Valid: "function f() { if (0) new a(b+c).d = 5 }"
PASS Invalid: "if (0) new a(b+c) = 5"
PASS Invalid: "function f() { if (0) new a(b+c) = 5 }"
PASS Valid: "if (0) new a(b+c) = 5"
PASS Valid: "function f() { if (0) new a(b+c) = 5 }"
PASS Valid: "([1 || 1].a = 1)"
PASS Valid: "function f() { ([1 || 1].a = 1) }"
PASS Valid: "({a: 1 || 1}.a = 1)"
......
......@@ -85,19 +85,19 @@ invalid("a.'l'");
valid ("a: +~!new a");
invalid("new -a");
valid ("new (-1)")
invalid("a: b: c: new f(x++)++")
valid ("a: b: c: new f(x++)++")
valid ("(a)++");
invalid("(1--).x");
valid ("(1--).x");
invalid("a-- ++");
invalid("(a:) --b");
invalid("++ -- ++ a");
invalid("++ new new a ++");
valid ("++ -- ++ a");
valid ("++ new new a ++");
valid ("delete void 0");
invalid("delete the void");
invalid("(a++");
invalid("++a--");
invalid("++((a))--");
invalid("(a.x++)++");
valid ("++a--");
valid ("++((a))--");
valid ("(a.x++)++");
invalid("1: null");
invalid("+-!~");
invalid("+-!~((");
......@@ -122,23 +122,23 @@ valid ("a in b instanceof delete -c");
invalid("a in instanceof b.l");
valid ("- - true % 5");
invalid("- false = 3");
invalid("a: b: c: (1 + null) = 3");
valid ("a: b: c: (1 + null) = 3");
valid ("a[2] = b.l += c /= 4 * 7 ^ !6");
invalid("a + typeof b += c in d");
invalid("typeof a &= typeof b");
invalid("a: ((typeof (a))) >>>= a || b.l && c");
valid ("a: ((typeof (a))) >>>= a || b.l && c");
valid ("a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g");
valid ("-void+x['y'].l == x.l != 5 - f[7]");
debug ("Function calls (and new with arguments)");
valid ("a()()()");
invalid("s: l: a[2](4 == 6, 5 = 6)(f[4], 6)");
valid ("s: l: a[2](4 == 6, 5 = 6)(f[4], 6)");
valid ("s: eval(a.apply(), b.call(c[5] - f[7]))");
invalid("a(");
invalid("a(5");
invalid("a(5,");
valid("a(5,)");
invalid("a(5,)");
invalid("a(5,6");
valid ("a(b[7], c <d> e.l, new a() > b)");
invalid("a(b[5)");
......@@ -158,7 +158,7 @@ valid ("function f() {}");
valid ("function f(a,b) {}");
invalid("function () {}");
invalid("function f(a b) {}");
valid("function f(a,) {}");
invalid("function f(a,) {}");
invalid("function f(a,");
invalid("function f(a, 1) {}");
valid ("function g(arguments, eval) {}");
......@@ -248,15 +248,15 @@ invalid("var 5 = 6");
valid ("while (0) var a, b, c=6, d, e, f=5*6, g=f*h, h");
invalid("var a = if (b) { c }");
invalid("var a = var b");
invalid("const a = b += c, a, a, a = (b - f())");
valid ("const a = b += c, a, a, a = (b - f())");
invalid("var a %= b | 5");
invalid("var (a) = 5");
invalid("var a = (4, b = 6");
invalid("const 'l' = 3");
invalid("var var = 3");
valid ("var varr = 3 in 1");
invalid("const a, a, a = void 7 - typeof 8, a = 8");
invalid("const x_x = 6 /= 7 ? e : f");
valid ("const a, a, a = void 7 - typeof 8, a = 8");
valid ("const x_x = 6 /= 7 ? e : f");
invalid("var a = ?");
invalid("const a = *7");
invalid("var a = :)");
......@@ -306,7 +306,7 @@ invalid("for ((a, b) in c) break");
invalid("for (a ? b : c in c) break");
invalid("for ((a ? b : c) in c) break");
valid ("for (var a in b in c) break");
invalid("for (var a = 5 += 6 in b) break");
valid ("for (var a = 5 += 6 in b) break");
invalid("for (var a += 5 in b) break");
invalid("for (var a = in b) break");
invalid("for (var a, b in b) break");
......@@ -315,7 +315,7 @@ invalid("for (var a, b = 8 in b) break");
valid ("for (var a = (b in c) in d) break");
invalid("for (var a = (b in c in d) break");
invalid("for (var (a) in b) { }");
invalid("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
valid ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
debug ("try statement");
......@@ -379,7 +379,7 @@ valid("if (0) obj.foo$; ")
valid("if (0) obj.foo_; ")
valid("if (0) obj.foo\\u03bb; ")
valid("if (0) new a(b+c).d = 5");
invalid("if (0) new a(b+c) = 5");
valid("if (0) new a(b+c) = 5");
valid("([1 || 1].a = 1)");
valid("({a: 1 || 1}.a = 1)");
......
......@@ -26,9 +26,9 @@ Test to ensure correct handling of --> as a single line comment when at the begi
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS 'should be a syntax error' --> threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS /**/ 1 --> threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 1 /**/ --> threw exception SyntaxError: Invalid left-hand side expression in postfix operation.
PASS 'should be a syntax error' --> threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS /**/ 1 --> threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS 1 /**/ --> threw exception ReferenceError: Invalid left-hand side expression in postfix operation.
PASS 1/*
*/--> is 1
PASS --> is undefined.
......
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