From 06f84630044de19cf619d5965a5e27275b835dc5 Mon Sep 17 00:00:00 2001 From: Francis McCabe Date: Fri, 28 Jun 2019 23:36:42 +0000 Subject: [PATCH] Revert "Let all early errors be SyntaxErrors." This reverts commit 99fd5b9b9d1fea426e9e62a5869c4b0592281475. Reason for revert: fails presubmit test: https://ci.chromium.org/p/v8/builders/ci/V8%20Presubmit/5238 and a nosnap test https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/34143 Original change's description: > Let all early errors be SyntaxErrors. > > Implement the spec change from the following TC39 PR: > https://github.com/tc39/ecma262/pull/1527 > > Bug: v8:9326 > Change-Id: I9639903b12e7621e323990e2335f00e0313a59c3 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643171 > Reviewed-by: Adam Klein > Reviewed-by: Toon Verwaest > Commit-Queue: Adam Klein > Cr-Commit-Position: refs/heads/master@{#62451} TBR=adamk@chromium.org,verwaest@chromium.org,rkirsling@gmail.com Change-Id: If63b97725e9737ad5a98800e1194caf8e9c1c43d No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:9326 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682393 Reviewed-by: Francis McCabe Commit-Queue: Francis McCabe Cr-Commit-Position: refs/heads/master@{#62452} --- AUTHORS | 1 - DEPS | 2 +- src/ast/scopes.cc | 3 +- src/common/globals.h | 2 + src/parsing/expression-scope.h | 3 +- src/parsing/parser-base.h | 40 ++-- src/parsing/parser.h | 16 +- .../pending-compilation-error-handler.cc | 29 ++- .../pending-compilation-error-handler.h | 11 +- src/parsing/preparser.h | 19 +- test/message/fail/new-target-assignment.out | 4 +- test/message/fail/new-target-postfix-op.out | 4 +- test/message/fail/new-target-prefix-op.out | 4 +- test/mjsunit/es6/new-target.js | 14 +- test/mjsunit/es6/templates.js | 20 +- test/mjsunit/es7/exponentiation-operator.js | 12 +- test/mjsunit/invalid-lhs.js | 44 ++--- test/mjsunit/regress/regress-8630.js | 6 +- test/mjsunit/regress/regress-900585.js | 2 +- test/mjsunit/regress/regress-crbug-351658.js | 2 +- .../fast/js/basic-strict-mode-expected.txt | 32 ++-- ...function-toString-parentheses-expected.txt | 174 +++++++++--------- .../fast/js/function-toString-parentheses.js | 17 +- .../fast/js/parser-syntax-check-expected.txt | 84 ++++----- test/webkit/fast/js/parser-syntax-check.js | 36 ++-- .../parser-xml-close-comment-expected.txt | 6 +- 26 files changed, 308 insertions(+), 279 deletions(-) diff --git a/AUTHORS b/AUTHORS index fd5a60b3d6..5998831f63 100644 --- a/AUTHORS +++ b/AUTHORS @@ -162,7 +162,6 @@ Rob Wu Robert Meijer Robert Mustacchi Robert Nagy -Ross Kirsling Ruben Bridgewater Ryan Dahl Sakthipriyan Vairamani (thefourtheye) diff --git a/DEPS b/DEPS index 40a7ac36d6..2c838cae7f 100644 --- a/DEPS +++ b/DEPS @@ -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': { diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc index 0ce37cdb00..09bbe5d39a 100644 --- a/src/ast/scopes.cc +++ b/src/ast/scopes.cc @@ -2465,7 +2465,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(); diff --git a/src/common/globals.h b/src/common/globals.h index 46fc0704ec..fc936c0e14 100644 --- a/src/common/globals.h +++ b/src/common/globals.h @@ -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, diff --git a/src/parsing/expression-scope.h b/src/parsing/expression-scope.h index 5896d8a3b0..1a33496c96 100644 --- a/src/parsing/expression-scope.h +++ b/src/parsing/expression-scope.h @@ -437,7 +437,8 @@ class ExpressionParsingScope : public ExpressionScope { } 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, diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h index 07618a7a80..b788f2e6c4 100644 --- a/src/parsing/parser-base.h +++ b/src/parsing/parser-base.h @@ -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(nullptr)); + static_cast(nullptr), kSyntaxError); } template - 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(nullptr)); + static_cast(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::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::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(nullptr), + kReferenceError); } } expression_scope()->ValidateAsPattern(expression, lhs_beg_pos, @@ -4301,7 +4306,7 @@ typename ParserBase::ExpressionT ParserBase::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 ParserBase::ExpressionT ParserBase::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::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::ExpressionT ParserBase::ParseV8Intrinsic() { if (has_spread) { ReportMessageAt(Scanner::Location(pos, position()), - MessageTemplate::kIntrinsicWithSpread); + MessageTemplate::kIntrinsicWithSpread, kSyntaxError); return impl()->FailureExpression(); } diff --git a/src/parsing/parser.h b/src/parsing/parser.h index b7fb19c26f..4bda674944 100644 --- a/src/parsing/parser.h +++ b/src/parsing/parser.h @@ -696,9 +696,11 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase) { // 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) { 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(); } diff --git a/src/parsing/pending-compilation-error-handler.cc b/src/parsing/pending-compilation-error-handler.cc index d792d5c184..b6331b2f9d 100644 --- a/src/parsing/pending-compilation-error-handler.cc +++ b/src/parsing/pending-compilation-error-handler.cc @@ -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 error = - factory->NewSyntaxError(error_details_.message(), argument); + Handle 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); diff --git a/src/parsing/pending-compilation-error-handler.h b/src/parsing/pending-compilation-error-handler.h index cb2908eaf8..84d7b9547c 100644 --- a/src/parsing/pending-compilation-error-handler.h +++ b/src/parsing/pending-compilation-error-handler.h @@ -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 warning_messages_; diff --git a/src/parsing/preparser.h b/src/parsing/preparser.h index f3325ccff0..133bfc623c 100644 --- a/src/parsing/preparser.h +++ b/src/parsing/preparser.h @@ -1483,9 +1483,11 @@ class PreParser : public ParserBase { // 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 { 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(); } diff --git a/test/message/fail/new-target-assignment.out b/test/message/fail/new-target-assignment.out index e868c4c82d..bc1492ca92 100644 --- a/test/message/fail/new-target-assignment.out +++ b/test/message/fail/new-target-assignment.out @@ -1,4 +1,4 @@ -*%(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 diff --git a/test/message/fail/new-target-postfix-op.out b/test/message/fail/new-target-postfix-op.out index 840f316cf9..1e8ef6be21 100644 --- a/test/message/fail/new-target-postfix-op.out +++ b/test/message/fail/new-target-postfix-op.out @@ -1,4 +1,4 @@ -*%(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 diff --git a/test/message/fail/new-target-prefix-op.out b/test/message/fail/new-target-prefix-op.out index 450e7af28a..a444087ec9 100644 --- a/test/message/fail/new-target-prefix-op.out +++ b/test/message/fail/new-target-prefix-op.out @@ -1,4 +1,4 @@ -*%(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 diff --git a/test/mjsunit/es6/new-target.js b/test/mjsunit/es6/new-target.js index 67ec96a9fd..c77c153cc0 100644 --- a/test/mjsunit/es6/new-target.js +++ b/test/mjsunit/es6/new-target.js @@ -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); })(); diff --git a/test/mjsunit/es6/templates.js b/test/mjsunit/es6/templates.js index 3da06b2b0f..3e113cb829 100644 --- a/test/mjsunit/es6/templates.js +++ b/test/mjsunit/es6/templates.js @@ -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 diff --git a/test/mjsunit/es7/exponentiation-operator.js b/test/mjsunit/es7/exponentiation-operator.js index 2c504a9f1e..9d934bdaac 100644 --- a/test/mjsunit/es7/exponentiation-operator.js +++ b/test/mjsunit/es7/exponentiation-operator.js @@ -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(); diff --git a/test/mjsunit/invalid-lhs.js b/test/mjsunit/invalid-lhs.js index aec841006a..92929b68e5 100644 --- a/test/mjsunit/invalid-lhs.js +++ b/test/mjsunit/invalid-lhs.js @@ -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); diff --git a/test/mjsunit/regress/regress-8630.js b/test/mjsunit/regress/regress-8630.js index 205fb1b8e1..4a5aa5409b 100644 --- a/test/mjsunit/regress/regress-8630.js +++ b/test/mjsunit/regress/regress-8630.js @@ -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 diff --git a/test/mjsunit/regress/regress-900585.js b/test/mjsunit/regress/regress-900585.js index 456f2c8ee6..8969644f95 100644 --- a/test/mjsunit/regress/regress-900585.js +++ b/test/mjsunit/regress/regress-900585.js @@ -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); diff --git a/test/mjsunit/regress/regress-crbug-351658.js b/test/mjsunit/regress/regress-crbug-351658.js index 3e53c744ef..ae6b50ec87 100644 --- a/test/mjsunit/regress/regress-crbug-351658.js +++ b/test/mjsunit/regress/regress-crbug-351658.js @@ -10,5 +10,5 @@ try { f(); assertUnreachable(); } catch(e) { - assertTrue(e instanceof SyntaxError); + assertTrue(e instanceof ReferenceError); } diff --git a/test/webkit/fast/js/basic-strict-mode-expected.txt b/test/webkit/fast/js/basic-strict-mode-expected.txt index 8d31cf32de..55c6edf808 100644 --- a/test/webkit/fast/js/basic-strict-mode-expected.txt +++ b/test/webkit/fast/js/basic-strict-mode-expected.txt @@ -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. diff --git a/test/webkit/fast/js/function-toString-parentheses-expected.txt b/test/webkit/fast/js/function-toString-parentheses-expected.txt index da0073e528..1d0f081b36 100644 --- a/test/webkit/fast/js/function-toString-parentheses-expected.txt +++ b/test/webkit/fast/js/function-toString-parentheses-expected.txt @@ -234,145 +234,145 @@ PASS compileAndSerialize('a || b || c') is 'a || b || c' PASS compileAndSerialize('(a || b) || c') is '(a || b) || c' PASS compileAndSerialize('a || (b || c)') is 'a || (b || c)' PASS compileAndSerialize('a = b = c') is 'a = b = c' -FAIL compileAndSerialize('(a = b) = c') should be (a = b) = c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) = c') should be (a = b) = c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b = c)') is 'a = (b = c)' PASS compileAndSerialize('a = b + c') is 'a = b + c' PASS compileAndSerialize('(a = b) + c') is '(a = b) + c' PASS compileAndSerialize('a = (b + c)') is 'a = (b + c)' -PASS compileAndSerialize('a + b = c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) = c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b = c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) = c') should be (a + b) = c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b = c)') is 'a + (b = c)' PASS compileAndSerialize('a *= b *= c') is 'a *= b *= c' -FAIL compileAndSerialize('(a *= b) *= c') should be (a *= b) *= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a *= b) *= c') should be (a *= b) *= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a *= (b *= c)') is 'a *= (b *= c)' PASS compileAndSerialize('a = b *= c') is 'a = b *= c' -FAIL compileAndSerialize('(a = b) *= c') should be (a = b) *= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) *= c') should be (a = b) *= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b *= c)') is 'a = (b *= c)' PASS compileAndSerialize('a *= b + c') is 'a *= b + c' PASS compileAndSerialize('(a *= b) + c') is '(a *= b) + c' PASS compileAndSerialize('a *= (b + c)') is 'a *= (b + c)' -PASS compileAndSerialize('a + b *= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) *= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b *= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) *= c') should be (a + b) *= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b *= c)') is 'a + (b *= c)' PASS compileAndSerialize('a /= b /= c') is 'a /= b /= c' -FAIL compileAndSerialize('(a /= b) /= c') should be (a /= b) /= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a /= b) /= c') should be (a /= b) /= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a /= (b /= c)') is 'a /= (b /= c)' PASS compileAndSerialize('a = b /= c') is 'a = b /= c' -FAIL compileAndSerialize('(a = b) /= c') should be (a = b) /= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) /= c') should be (a = b) /= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b /= c)') is 'a = (b /= c)' PASS compileAndSerialize('a /= b + c') is 'a /= b + c' PASS compileAndSerialize('(a /= b) + c') is '(a /= b) + c' PASS compileAndSerialize('a /= (b + c)') is 'a /= (b + c)' -PASS compileAndSerialize('a + b /= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) /= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b /= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) /= c') should be (a + b) /= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b /= c)') is 'a + (b /= c)' PASS compileAndSerialize('a %= b %= c') is 'a %= b %= c' -FAIL compileAndSerialize('(a %= b) %= c') should be (a %= b) %= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a %= b) %= c') should be (a %= b) %= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a %= (b %= c)') is 'a %= (b %= c)' PASS compileAndSerialize('a = b %= c') is 'a = b %= c' -FAIL compileAndSerialize('(a = b) %= c') should be (a = b) %= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) %= c') should be (a = b) %= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b %= c)') is 'a = (b %= c)' PASS compileAndSerialize('a %= b + c') is 'a %= b + c' PASS compileAndSerialize('(a %= b) + c') is '(a %= b) + c' PASS compileAndSerialize('a %= (b + c)') is 'a %= (b + c)' -PASS compileAndSerialize('a + b %= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) %= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b %= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) %= c') should be (a + b) %= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b %= c)') is 'a + (b %= c)' PASS compileAndSerialize('a += b += c') is 'a += b += c' -FAIL compileAndSerialize('(a += b) += c') should be (a += b) += c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a += b) += c') should be (a += b) += c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a += (b += c)') is 'a += (b += c)' PASS compileAndSerialize('a = b += c') is 'a = b += c' -FAIL compileAndSerialize('(a = b) += c') should be (a = b) += c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) += c') should be (a = b) += c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b += c)') is 'a = (b += c)' PASS compileAndSerialize('a += b + c') is 'a += b + c' PASS compileAndSerialize('(a += b) + c') is '(a += b) + c' PASS compileAndSerialize('a += (b + c)') is 'a += (b + c)' -PASS compileAndSerialize('a + b += c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) += c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b += c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) += c') should be (a + b) += c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b += c)') is 'a + (b += c)' PASS compileAndSerialize('a -= b -= c') is 'a -= b -= c' -FAIL compileAndSerialize('(a -= b) -= c') should be (a -= b) -= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a -= b) -= c') should be (a -= b) -= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a -= (b -= c)') is 'a -= (b -= c)' PASS compileAndSerialize('a = b -= c') is 'a = b -= c' -FAIL compileAndSerialize('(a = b) -= c') should be (a = b) -= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) -= c') should be (a = b) -= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b -= c)') is 'a = (b -= c)' PASS compileAndSerialize('a -= b + c') is 'a -= b + c' PASS compileAndSerialize('(a -= b) + c') is '(a -= b) + c' PASS compileAndSerialize('a -= (b + c)') is 'a -= (b + c)' -PASS compileAndSerialize('a + b -= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) -= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b -= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) -= c') should be (a + b) -= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b -= c)') is 'a + (b -= c)' PASS compileAndSerialize('a <<= b <<= c') is 'a <<= b <<= c' -FAIL compileAndSerialize('(a <<= b) <<= c') should be (a <<= b) <<= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a <<= b) <<= c') should be (a <<= b) <<= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a <<= (b <<= c)') is 'a <<= (b <<= c)' PASS compileAndSerialize('a = b <<= c') is 'a = b <<= c' -FAIL compileAndSerialize('(a = b) <<= c') should be (a = b) <<= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) <<= c') should be (a = b) <<= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b <<= c)') is 'a = (b <<= c)' PASS compileAndSerialize('a <<= b + c') is 'a <<= b + c' PASS compileAndSerialize('(a <<= b) + c') is '(a <<= b) + c' PASS compileAndSerialize('a <<= (b + c)') is 'a <<= (b + c)' -PASS compileAndSerialize('a + b <<= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) <<= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b <<= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) <<= c') should be (a + b) <<= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b <<= c)') is 'a + (b <<= c)' PASS compileAndSerialize('a >>= b >>= c') is 'a >>= b >>= c' -FAIL compileAndSerialize('(a >>= b) >>= c') should be (a >>= b) >>= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a >>= b) >>= c') should be (a >>= b) >>= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a >>= (b >>= c)') is 'a >>= (b >>= c)' PASS compileAndSerialize('a = b >>= c') is 'a = b >>= c' -FAIL compileAndSerialize('(a = b) >>= c') should be (a = b) >>= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) >>= c') should be (a = b) >>= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b >>= c)') is 'a = (b >>= c)' PASS compileAndSerialize('a >>= b + c') is 'a >>= b + c' PASS compileAndSerialize('(a >>= b) + c') is '(a >>= b) + c' PASS compileAndSerialize('a >>= (b + c)') is 'a >>= (b + c)' -PASS compileAndSerialize('a + b >>= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) >>= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b >>= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) >>= c') should be (a + b) >>= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b >>= c)') is 'a + (b >>= c)' PASS compileAndSerialize('a >>>= b >>>= c') is 'a >>>= b >>>= c' -FAIL compileAndSerialize('(a >>>= b) >>>= c') should be (a >>>= b) >>>= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a >>>= b) >>>= c') should be (a >>>= b) >>>= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a >>>= (b >>>= c)') is 'a >>>= (b >>>= c)' PASS compileAndSerialize('a = b >>>= c') is 'a = b >>>= c' -FAIL compileAndSerialize('(a = b) >>>= c') should be (a = b) >>>= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) >>>= c') should be (a = b) >>>= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b >>>= c)') is 'a = (b >>>= c)' PASS compileAndSerialize('a >>>= b + c') is 'a >>>= b + c' PASS compileAndSerialize('(a >>>= b) + c') is '(a >>>= b) + c' PASS compileAndSerialize('a >>>= (b + c)') is 'a >>>= (b + c)' -PASS compileAndSerialize('a + b >>>= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) >>>= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b >>>= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) >>>= c') should be (a + b) >>>= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b >>>= c)') is 'a + (b >>>= c)' PASS compileAndSerialize('a &= b &= c') is 'a &= b &= c' -FAIL compileAndSerialize('(a &= b) &= c') should be (a &= b) &= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a &= b) &= c') should be (a &= b) &= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a &= (b &= c)') is 'a &= (b &= c)' PASS compileAndSerialize('a = b &= c') is 'a = b &= c' -FAIL compileAndSerialize('(a = b) &= c') should be (a = b) &= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) &= c') should be (a = b) &= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b &= c)') is 'a = (b &= c)' PASS compileAndSerialize('a &= b + c') is 'a &= b + c' PASS compileAndSerialize('(a &= b) + c') is '(a &= b) + c' PASS compileAndSerialize('a &= (b + c)') is 'a &= (b + c)' -PASS compileAndSerialize('a + b &= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) &= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b &= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) &= c') should be (a + b) &= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b &= c)') is 'a + (b &= c)' PASS compileAndSerialize('a ^= b ^= c') is 'a ^= b ^= c' -FAIL compileAndSerialize('(a ^= b) ^= c') should be (a ^= b) ^= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a ^= b) ^= c') should be (a ^= b) ^= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a ^= (b ^= c)') is 'a ^= (b ^= c)' PASS compileAndSerialize('a = b ^= c') is 'a = b ^= c' -FAIL compileAndSerialize('(a = b) ^= c') should be (a = b) ^= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) ^= c') should be (a = b) ^= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b ^= c)') is 'a = (b ^= c)' PASS compileAndSerialize('a ^= b + c') is 'a ^= b + c' PASS compileAndSerialize('(a ^= b) + c') is '(a ^= b) + c' PASS compileAndSerialize('a ^= (b + c)') is 'a ^= (b + c)' -PASS compileAndSerialize('a + b ^= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) ^= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b ^= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) ^= c') should be (a + b) ^= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b ^= c)') is 'a + (b ^= c)' PASS compileAndSerialize('a |= b |= c') is 'a |= b |= c' -FAIL compileAndSerialize('(a |= b) |= c') should be (a |= b) |= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a |= b) |= c') should be (a |= b) |= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a |= (b |= c)') is 'a |= (b |= c)' PASS compileAndSerialize('a = b |= c') is 'a = b |= c' -FAIL compileAndSerialize('(a = b) |= c') should be (a = b) |= c. Threw exception SyntaxError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(a = b) |= c') should be (a = b) |= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a = (b |= c)') is 'a = (b |= c)' PASS compileAndSerialize('a |= b + c') is 'a |= b + c' PASS compileAndSerialize('(a |= b) + c') is '(a |= b) + c' PASS compileAndSerialize('a |= (b + c)') is 'a |= (b + c)' -PASS compileAndSerialize('a + b |= c') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(a + b) |= c') threw exception SyntaxError: Invalid left-hand side in assignment. +PASS compileAndSerialize('a + b |= c') threw exception ReferenceError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(a + b) |= c') should be (a + b) |= c. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerialize('a + (b |= c)') is 'a + (b |= c)' PASS compileAndSerialize('delete a + b') is 'delete a + b' PASS compileAndSerialize('(delete a) + b') is '(delete a) + b' @@ -391,12 +391,12 @@ PASS compileAndSerialize('!typeof a') is '!typeof a' PASS compileAndSerialize('!(typeof a)') is '!(typeof a)' PASS compileAndSerialize('++a + b') is '++a + b' PASS compileAndSerialize('(++a) + b') is '(++a) + b' -PASS compileAndSerialize('++(a + b)') threw exception SyntaxError: Invalid left-hand side expression in prefix operation. +FAIL compileAndSerialize('++(a + b)') should be ++(a + b). Threw exception ReferenceError: Invalid left-hand side expression in prefix operation PASS compileAndSerialize('!++a') is '!++a' PASS compileAndSerialize('!(++a)') is '!(++a)' PASS compileAndSerialize('--a + b') is '--a + b' PASS compileAndSerialize('(--a) + b') is '(--a) + b' -PASS compileAndSerialize('--(a + b)') threw exception SyntaxError: Invalid left-hand side expression in prefix operation. +FAIL compileAndSerialize('--(a + b)') should be --(a + b). Threw exception ReferenceError: Invalid left-hand side expression in prefix operation PASS compileAndSerialize('!--a') is '!--a' PASS compileAndSerialize('!(--a)') is '!(--a)' PASS compileAndSerialize('+ a + b') is '+ a + b' @@ -421,10 +421,10 @@ PASS compileAndSerialize('!!a') is '!!a' PASS compileAndSerialize('!(!a)') is '!(!a)' PASS compileAndSerialize('!a++') is '!a++' PASS compileAndSerialize('!(a++)') is '!(a++)' -PASS compileAndSerialize('(!a)++') threw exception SyntaxError: Invalid left-hand side expression in postfix operation. +FAIL compileAndSerialize('(!a)++') should be (!a)++. Threw exception ReferenceError: Invalid left-hand side expression in postfix operation PASS compileAndSerialize('!a--') is '!a--' PASS compileAndSerialize('!(a--)') is '!(a--)' -PASS compileAndSerialize('(!a)--') threw exception SyntaxError: Invalid left-hand side expression in postfix operation. +FAIL compileAndSerialize('(!a)--') should be (!a)--. Threw exception ReferenceError: Invalid left-hand side expression in postfix operation PASS compileAndSerialize('(-1)[a]') is '(-1)[a]' PASS compileAndSerialize('(-1)[a] = b') is '(-1)[a] = b' PASS compileAndSerialize('(-1)[a] += b') is '(-1)[a] += b' @@ -464,42 +464,42 @@ PASS compileAndSerialize('(1).a += b') is '(1).a += b' PASS compileAndSerialize('(1).a++') is '(1).a++' PASS compileAndSerialize('++(1).a') is '++(1).a' PASS compileAndSerialize('(1).a()') is '(1).a()' -PASS compileAndSerialize('(-1) = a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) = a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 = a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) *= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) *= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 *= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) /= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) /= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 /= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) %= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) %= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 %= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) += a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) += a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 += a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) -= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) -= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 -= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) <<= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) <<= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 <<= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) >>= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) >>= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 >>= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) >>>= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) >>>= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 >>>= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) &= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) &= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 &= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) ^= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) ^= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 ^= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(-1) |= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('(- 0) |= a') threw exception SyntaxError: Invalid left-hand side in assignment. -PASS compileAndSerialize('1 |= a') threw exception SyntaxError: Invalid left-hand side in assignment. +FAIL compileAndSerialize('(-1) = a') should be (-1) = a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) = a') should be (- 0) = a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 = a') should be 1 = a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) *= a') should be (-1) *= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) *= a') should be (- 0) *= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 *= a') should be 1 *= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) /= a') should be (-1) /= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) /= a') should be (- 0) /= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 /= a') should be 1 /= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) %= a') should be (-1) %= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) %= a') should be (- 0) %= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 %= a') should be 1 %= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) += a') should be (-1) += a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) += a') should be (- 0) += a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 += a') should be 1 += a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) -= a') should be (-1) -= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) -= a') should be (- 0) -= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 -= a') should be 1 -= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) <<= a') should be (-1) <<= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) <<= a') should be (- 0) <<= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 <<= a') should be 1 <<= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) >>= a') should be (-1) >>= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) >>= a') should be (- 0) >>= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 >>= a') should be 1 >>= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) >>>= a') should be (-1) >>>= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) >>>= a') should be (- 0) >>>= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 >>>= a') should be 1 >>>= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) &= a') should be (-1) &= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) &= a') should be (- 0) &= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 &= a') should be 1 &= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) ^= a') should be (-1) ^= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) ^= a') should be (- 0) ^= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 ^= a') should be 1 ^= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(-1) |= a') should be (-1) |= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('(- 0) |= a') should be (- 0) |= a. Threw exception ReferenceError: Invalid left-hand side in assignment +FAIL compileAndSerialize('1 |= a') should be 1 |= a. Threw exception ReferenceError: Invalid left-hand side in assignment PASS compileAndSerializeLeftmostTest('({ }).x') is '({ }).x' PASS compileAndSerializeLeftmostTest('x = { }') is 'x = { }' PASS compileAndSerializeLeftmostTest('(function () { })()') is '(function () { })()' diff --git a/test/webkit/fast/js/function-toString-parentheses.js b/test/webkit/fast/js/function-toString-parentheses.js index af831976b6..6bc62ab811 100644 --- a/test/webkit/fast/js/function-toString-parentheses.js +++ b/test/webkit/fast/js/function-toString-parentheses.js @@ -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'"); diff --git a/test/webkit/fast/js/parser-syntax-check-expected.txt b/test/webkit/fast/js/parser-syntax-check-expected.txt index 8bab89ad11..f6dbe354e7 100644 --- a/test/webkit/fast/js/parser-syntax-check-expected.txt +++ b/test/webkit/fast/js/parser-syntax-check-expected.txt @@ -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 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)" diff --git a/test/webkit/fast/js/parser-syntax-check.js b/test/webkit/fast/js/parser-syntax-check.js index 7dbd5583b2..15be4b048b 100644 --- a/test/webkit/fast/js/parser-syntax-check.js +++ b/test/webkit/fast/js/parser-syntax-check.js @@ -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 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)"); diff --git a/test/webkit/parser-xml-close-comment-expected.txt b/test/webkit/parser-xml-close-comment-expected.txt index 34a9f637f9..b6aebe3d06 100644 --- a/test/webkit/parser-xml-close-comment-expected.txt +++ b/test/webkit/parser-xml-close-comment-expected.txt @@ -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.