Changeset 245406 in webkit


Ignore:
Timestamp:
May 16, 2019 1:08:22 PM (5 years ago)
Author:
Ross Kirsling
Message:

[JSC] Invalid AssignmentTargetType should be an early error.
https://bugs.webkit.org/show_bug.cgi?id=197603

Reviewed by Keith Miller.

JSTests:

  • test262/expectations.yaml:

Update expectations to reflect new SyntaxErrors.
(Ideally, these should all be viewed as passing in the near future.)

  • stress/async-await-basic.js:
  • stress/big-int-literals.js:

Update tests to reflect new SyntaxErrors.

  • ChakraCore.yaml:
  • ChakraCore/test/EH/try6.baseline-jsc:
  • ChakraCore/test/Error/variousErrors3.baseline-jsc: Added.

Update baselines to reflect new SyntaxErrors.

Source/JavaScriptCore:

Since ES6, expressions like 0++, ++0, 0 = 0, and 0 += 0 are all specified as early errors:

https://tc39.github.io/ecma262/#sec-update-expressions-static-semantics-early-errors
https://tc39.github.io/ecma262/#sec-assignment-operators-static-semantics-early-errors

We currently throw late ReferenceErrors for these -- let's turn them into early SyntaxErrors.
(This is based on the expectation that https://github.com/tc39/ecma262/pull/1527 will be accepted;
if that doesn't come to pass, we can subsequently introduce early ReferenceError and revise these.)

  • bytecompiler/NodesCodegen.cpp:

(JSC::PostfixNode::emitBytecode): Add an assert for "function call LHS" case.
(JSC::PrefixNode::emitBytecode): Add an assert for "function call LHS" case.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::isLocation): Added.
(JSC::ASTBuilder::isAssignmentLocation): Fix misleading parameter name.
(JSC::ASTBuilder::isFunctionCall): Added.
(JSC::ASTBuilder::makeAssignNode): Add an assert for "function call LHS" case.

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::isLocation): Added.
(JSC::SyntaxChecker::isAssignmentLocation): Fix incorrect definition and align with ASTBuilder.
(JSC::SyntaxChecker::isFunctionCall): Added.

  • parser/Nodes.h:

(JSC::ExpressionNode::isFunctionCall const): Added.
Ensure that the parser can check whether an expression node is a function call.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::isSimpleAssignmentTarget): Added.
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parseUnaryExpression): See below.

  • parser/Parser.h:

Throw SyntaxError whenever an assignment or update expression's target is invalid.
Unfortunately, it seems that web compatibility obliges us to exempt the "function call LHS" case in sloppy mode.
(https://github.com/tc39/ecma262/issues/257#issuecomment-195106880)

Additional cleanup items:

  • Make use of semanticFailIfTrue for isMetaProperty checks, as it's equivalent.
  • Rename requiresLExpr to hasPrefixUpdateOp since it's now confusing, and get rid of modifiesExpr since it refers to the exact same condition.
  • Stop setting lastOperator near the end -- one case was incorrect and regardless neither is used.

LayoutTests:

  • fast/events/window-onerror4-expected.txt:
  • ietestcenter/Javascript/11.13.1-1-1-expected.txt:
  • ietestcenter/Javascript/11.13.1-1-2-expected.txt:
  • ietestcenter/Javascript/11.13.1-1-3-expected.txt:
  • ietestcenter/Javascript/11.13.1-1-4-expected.txt:
  • js/basic-strict-mode-expected.txt:
  • js/dom/assign-expected.txt:
  • js/dom/line-column-numbers-expected.txt:
  • js/dom/line-column-numbers.html:
  • js/dom/postfix-syntax-expected.txt:
  • js/dom/prefix-syntax-expected.txt:
  • js/dom/script-tests/line-column-numbers.js:
  • js/function-toString-parentheses-expected.txt:
  • js/parser-syntax-check-expected.txt:
  • js/parser-xml-close-comment-expected.txt:
  • js/script-tests/function-toString-parentheses.js:
  • js/script-tests/parser-syntax-check.js:

Update tests & expectations to reflect new SyntaxErrors.

  • js/script-tests/toString-prefix-postfix-preserve-parens.js:
  • js/toString-prefix-postfix-preserve-parens-expected.txt:

None of the prefix/postfix tests make sense here now that they're all SyntaxErrors;
remove them and just leave the typeof tests.

Location:
trunk
Files:
1 added
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChakraCore.yaml

    r244972 r245406  
    552552  cmd: runChakra :baseline, "NoException", "CallNonFunction_3.baseline-jsc", []
    553553- path: ChakraCore/test/Error/variousErrors.js
    554   cmd: runChakra :baseline, "NoException", "variousErrors3.baseline", []
     554  cmd: runChakra :baseline, "NoException", "variousErrors3.baseline-jsc", []
    555555- path: ChakraCore/test/Error/bug560940.js
    556556  cmd: runChakra :pass, "NoException", "", []
  • trunk/JSTests/ChakraCore/test/EH/try6.baseline-jsc

    r205387 r245406  
    1717Except foobaz 2 thrown
    1818english (passed)
    19 ReferenceError: Postfix ++ operator applied to value that is not a reference.
     19SyntaxError: Postfix ++ operator applied to value that is not a reference.
  • trunk/JSTests/ChangeLog

    r245341 r245406  
     12019-05-16  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] Invalid AssignmentTargetType should be an early error.
     4        https://bugs.webkit.org/show_bug.cgi?id=197603
     5
     6        Reviewed by Keith Miller.
     7
     8        * test262/expectations.yaml:
     9        Update expectations to reflect new SyntaxErrors.
     10        (Ideally, these should all be viewed as passing in the near future.)
     11
     12        * stress/async-await-basic.js:
     13        * stress/big-int-literals.js:
     14        Update tests to reflect new SyntaxErrors.
     15
     16        * ChakraCore.yaml:
     17        * ChakraCore/test/EH/try6.baseline-jsc:
     18        * ChakraCore/test/Error/variousErrors3.baseline-jsc: Added.
     19        Update baselines to reflect new SyntaxErrors.
     20
    1212019-05-15  Saam Barati  <sbarati@apple.com>
    222
  • trunk/JSTests/stress/async-await-basic.js

    r223043 r245406  
    271271    log.push('step 5 ' + t3);
    272272
    273     try {
    274         var t4 = ++await 1;
    275     } catch(e) {
    276         if (e instanceof ReferenceError) {
    277             log.push('step 6 ');
    278         }
    279     }
    280 
    281     try {
    282         var t5 = --await 1;
    283     } catch(e) {
    284         if (e instanceof ReferenceError) {
    285             log.push('step 7');
    286         }
    287     }
     273    shouldThrowSyntaxError("var t4 = ++await 1;");
     274    shouldThrowSyntaxError("var t5 = --await 1;");
    288275
    289276    return void await 'test';
     
    292279
    293280shouldBeAsync(undefined, () => awaitEpression(5));
    294 shouldBe("start:5 step 1 step 2 -2 step 3 12345 step 4 -54321 step 5 false step 6  step 7", log.join(" "));
     281shouldBe("start:5 step 1 step 2 -2 step 3 12345 step 4 -54321 step 5 false", log.join(" "));
    295282
    296283// MethoodDefinition SyntaxErrors
  • trunk/JSTests/stress/big-int-literals.js

    r225799 r245406  
    105105assertThrowSyntaxError("1a0nn");
    106106assertThrowSyntaxError("10E20n");
    107 
    108 try {
    109     eval("--10n");
    110     assert(false);
    111 } catch(e) {
    112     assert(e instanceof ReferenceError);
    113 }
     107assertThrowSyntaxError("--10n");
  • trunk/JSTests/test262/expectations.yaml

    r245201 r245406  
    18221822  default: 'Test262Error: Expected obj[0] to have configurable:false.'
    18231823test/language/asi/S7.9_A5.7_T1.js:
    1824   default: 'Test262: This statement should not be evaluated.'
     1824  default: 'SyntaxError: The prefix-increment operator requires a reference expression.'
    18251825  strict mode: 'SyntaxError: The prefix-increment operator requires a reference expression.'
    18261826test/language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js:
     
    20752075  strict mode: 'Test262Error: Expected SameValue(«true», «false») to be true'
    20762076test/language/expressions/assignment/non-simple-target.js:
    2077   default: 'Test262: This statement should not be evaluated.'
    2078   strict mode: 'Test262: This statement should not be evaluated.'
     2077  default: 'SyntaxError: Left side of assignment is not a reference.'
     2078  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    20792079test/language/expressions/assignment/target-boolean.js:
    2080   default: 'Test262: This statement should not be evaluated.'
    2081   strict mode: 'Test262: This statement should not be evaluated.'
     2080  default: 'SyntaxError: Left side of assignment is not a reference.'
     2081  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    20822082test/language/expressions/assignment/target-cover-newtarget.js:
    20832083  default: "SyntaxError: new.target can't be the left hand side of an assignment expression."
    20842084  strict mode: "SyntaxError: new.target can't be the left hand side of an assignment expression."
    20852085test/language/expressions/assignment/target-cover-yieldexpr.js:
    2086   default: 'Test262: This statement should not be evaluated.'
    2087   strict mode: 'Test262: This statement should not be evaluated.'
     2086  default: 'SyntaxError: Left side of assignment is not a reference.'
     2087  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    20882088test/language/expressions/assignment/target-newtarget.js:
    20892089  default: "SyntaxError: new.target can't be the left hand side of an assignment expression."
    20902090  strict mode: "SyntaxError: new.target can't be the left hand side of an assignment expression."
    20912091test/language/expressions/assignment/target-null.js:
    2092   default: 'Test262: This statement should not be evaluated.'
    2093   strict mode: 'Test262: This statement should not be evaluated.'
     2092  default: 'SyntaxError: Left side of assignment is not a reference.'
     2093  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    20942094test/language/expressions/assignment/target-number.js:
    2095   default: 'Test262: This statement should not be evaluated.'
    2096   strict mode: 'Test262: This statement should not be evaluated.'
     2095  default: 'SyntaxError: Left side of assignment is not a reference.'
     2096  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    20972097test/language/expressions/assignment/target-string.js:
    2098   default: 'Test262: This statement should not be evaluated.'
    2099   strict mode: 'Test262: This statement should not be evaluated.'
     2098  default: 'SyntaxError: Left side of assignment is not a reference.'
     2099  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    21002100test/language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js:
    21012101  default: 'Test262: This statement should not be evaluated.'
     
    21052105  strict mode: 'Test262: This statement should not be evaluated.'
    21062106test/language/expressions/async-function/early-errors-expression-not-simple-assignment-target.js:
    2107   default: 'Test262: This statement should not be evaluated.'
    2108   strict mode: 'Test262: This statement should not be evaluated.'
     2107  default: 'SyntaxError: Left side of assignment is not a reference.'
     2108  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    21092109test/language/expressions/await/early-errors-await-not-simple-assignment-target.js:
    2110   default: 'Test262: This statement should not be evaluated.'
    2111   strict mode: 'Test262: This statement should not be evaluated.'
     2110  default: 'SyntaxError: Left side of assignment is not a reference.'
     2111  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    21122112test/language/expressions/call/eval-realm-indirect.js:
    21132113  default: 'Test262Error: Expected SameValue(«inside», «outside») to be true'
     
    23152315  strict mode: 'Test262Error: Expected true but got false'
    23162316test/language/expressions/compound-assignment/add-non-simple.js:
    2317   default: 'Test262: This statement should not be evaluated.'
    2318   strict mode: 'Test262: This statement should not be evaluated.'
     2317  default: 'SyntaxError: Left side of assignment is not a reference.'
     2318  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23192319test/language/expressions/compound-assignment/btws-and-non-simple.js:
    2320   default: 'Test262: This statement should not be evaluated.'
    2321   strict mode: 'Test262: This statement should not be evaluated.'
     2320  default: 'SyntaxError: Left side of assignment is not a reference.'
     2321  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23222322test/language/expressions/compound-assignment/btws-or-non-simple.js:
    2323   default: 'Test262: This statement should not be evaluated.'
    2324   strict mode: 'Test262: This statement should not be evaluated.'
     2323  default: 'SyntaxError: Left side of assignment is not a reference.'
     2324  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23252325test/language/expressions/compound-assignment/btws-xor-non-simple.js:
    2326   default: 'Test262: This statement should not be evaluated.'
    2327   strict mode: 'Test262: This statement should not be evaluated.'
     2326  default: 'SyntaxError: Left side of assignment is not a reference.'
     2327  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23282328test/language/expressions/compound-assignment/div-non-simple.js:
    2329   default: 'Test262: This statement should not be evaluated.'
    2330   strict mode: 'Test262: This statement should not be evaluated.'
     2329  default: 'SyntaxError: Left side of assignment is not a reference.'
     2330  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23312331test/language/expressions/compound-assignment/left-shift-non-simple.js:
    2332   default: 'Test262: This statement should not be evaluated.'
    2333   strict mode: 'Test262: This statement should not be evaluated.'
     2332  default: 'SyntaxError: Left side of assignment is not a reference.'
     2333  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23342334test/language/expressions/compound-assignment/mod-div-non-simple.js:
    2335   default: 'Test262: This statement should not be evaluated.'
    2336   strict mode: 'Test262: This statement should not be evaluated.'
     2335  default: 'SyntaxError: Left side of assignment is not a reference.'
     2336  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23372337test/language/expressions/compound-assignment/mult-non-simple.js:
    2338   default: 'Test262: This statement should not be evaluated.'
    2339   strict mode: 'Test262: This statement should not be evaluated.'
     2338  default: 'SyntaxError: Left side of assignment is not a reference.'
     2339  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23402340test/language/expressions/compound-assignment/right-shift-non-simple.js:
    2341   default: 'Test262: This statement should not be evaluated.'
    2342   strict mode: 'Test262: This statement should not be evaluated.'
     2341  default: 'SyntaxError: Left side of assignment is not a reference.'
     2342  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23432343test/language/expressions/compound-assignment/subtract-non-simple.js:
    2344   default: 'Test262: This statement should not be evaluated.'
    2345   strict mode: 'Test262: This statement should not be evaluated.'
     2344  default: 'SyntaxError: Left side of assignment is not a reference.'
     2345  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23462346test/language/expressions/compound-assignment/u-right-shift-non-simple.js:
    2347   default: 'Test262: This statement should not be evaluated.'
    2348   strict mode: 'Test262: This statement should not be evaluated.'
     2347  default: 'SyntaxError: Left side of assignment is not a reference.'
     2348  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23492349test/language/expressions/conditional/in-branch-1.js:
    23502350  default: "SyntaxError: Unexpected keyword 'in'. Expected ':' in ternary operator."
    23512351  strict mode: "SyntaxError: Unexpected keyword 'in'. Expected ':' in ternary operator."
    23522352test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-1-update-expression.js:
    2353   default: 'Test262: This statement should not be evaluated.'
    2354   strict mode: 'Test262: This statement should not be evaluated.'
     2353  default: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
     2354  strict mode: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
    23552355test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-10-lhs-assignment-operator-assignment-expression.js:
    2356   default: 'Test262: This statement should not be evaluated.'
    2357   strict mode: 'Test262: This statement should not be evaluated.'
     2356  default: 'SyntaxError: Left side of assignment is not a reference.'
     2357  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23582358test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-11-lhs-assignment-operator-assignment-expression.js:
    2359   default: 'Test262: This statement should not be evaluated.'
    2360   strict mode: 'Test262: This statement should not be evaluated.'
     2359  default: 'SyntaxError: Left side of assignment is not a reference.'
     2360  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23612361test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-12-lhs-assignment-operator-assignment-expression.js:
    2362   default: 'Test262: This statement should not be evaluated.'
    2363   strict mode: 'Test262: This statement should not be evaluated.'
     2362  default: 'SyntaxError: Left side of assignment is not a reference.'
     2363  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23642364test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-13-lhs-assignment-operator-assignment-expression.js:
    2365   default: 'Test262: This statement should not be evaluated.'
    2366   strict mode: 'Test262: This statement should not be evaluated.'
     2365  default: 'SyntaxError: Left side of assignment is not a reference.'
     2366  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23672367test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-14-lhs-assignment-operator-assignment-expression.js:
    2368   default: 'Test262: This statement should not be evaluated.'
    2369   strict mode: 'Test262: This statement should not be evaluated.'
     2368  default: 'SyntaxError: Left side of assignment is not a reference.'
     2369  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23702370test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-15-lhs-assignment-operator-assignment-expression.js:
    2371   default: 'Test262: This statement should not be evaluated.'
    2372   strict mode: 'Test262: This statement should not be evaluated.'
     2371  default: 'SyntaxError: Left side of assignment is not a reference.'
     2372  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23732373test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-16-lhs-assignment-operator-assignment-expression.js:
    2374   default: 'Test262: This statement should not be evaluated.'
    2375   strict mode: 'Test262: This statement should not be evaluated.'
     2374  default: 'SyntaxError: Left side of assignment is not a reference.'
     2375  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23762376test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-17-lhs-assignment-operator-assignment-expression.js:
    2377   default: 'Test262: This statement should not be evaluated.'
    2378   strict mode: 'Test262: This statement should not be evaluated.'
     2377  default: 'SyntaxError: Left side of assignment is not a reference.'
     2378  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23792379test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-2-update-expression.js:
    2380   default: 'Test262: This statement should not be evaluated.'
    2381   strict mode: 'Test262: This statement should not be evaluated.'
     2380  default: 'SyntaxError: Postfix -- operator applied to value that is not a reference.'
     2381  strict mode: 'SyntaxError: Postfix -- operator applied to value that is not a reference.'
    23822382test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-3-update-expression.js:
    2383   default: 'Test262: This statement should not be evaluated.'
    2384   strict mode: 'Test262: This statement should not be evaluated.'
     2383  default: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
     2384  strict mode: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
    23852385test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-4-update-expression.js:
    2386   default: 'Test262: This statement should not be evaluated.'
    2387   strict mode: 'Test262: This statement should not be evaluated.'
     2386  default: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
     2387  strict mode: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
    23882388test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-5-lhs-equals-assignment-expression.js:
    2389   default: 'Test262: This statement should not be evaluated.'
    2390   strict mode: 'Test262: This statement should not be evaluated.'
     2389  default: 'SyntaxError: Left side of assignment is not a reference.'
     2390  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23912391test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-6-lhs-assignment-operator-assignment-expression.js:
    2392   default: 'Test262: This statement should not be evaluated.'
    2393   strict mode: 'Test262: This statement should not be evaluated.'
     2392  default: 'SyntaxError: Left side of assignment is not a reference.'
     2393  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23942394test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-7-lhs-assignment-operator-assignment-expression.js:
    2395   default: 'Test262: This statement should not be evaluated.'
    2396   strict mode: 'Test262: This statement should not be evaluated.'
     2395  default: 'SyntaxError: Left side of assignment is not a reference.'
     2396  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    23972397test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-8-lhs-assignment-operator-assignment-expression.js:
    2398   default: 'Test262: This statement should not be evaluated.'
    2399   strict mode: 'Test262: This statement should not be evaluated.'
     2398  default: 'SyntaxError: Left side of assignment is not a reference.'
     2399  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    24002400test/language/expressions/dynamic-import/syntax/invalid/invalid-asssignmenttargettype-reference-error-9-lhs-assignment-operator-assignment-expression.js:
    2401   default: 'Test262: This statement should not be evaluated.'
    2402   strict mode: 'Test262: This statement should not be evaluated.'
     2401  default: 'SyntaxError: Left side of assignment is not a reference.'
     2402  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    24032403test/language/expressions/function/name.js:
    24042404  default: 'Test262Error: Expected SameValue(«true», «false») to be true'
     
    24922492  strict mode: "SyntaxError: new.target can't come before a postfix operator."
    24932493test/language/expressions/postfix-decrement/target-cover-yieldexpr.js:
    2494   default: 'Test262: This statement should not be evaluated.'
    2495   strict mode: 'Test262: This statement should not be evaluated.'
     2494  default: 'SyntaxError: Postfix -- operator applied to value that is not a reference.'
     2495  strict mode: 'SyntaxError: Postfix -- operator applied to value that is not a reference.'
    24962496test/language/expressions/postfix-decrement/target-newtarget.js:
    24972497  default: "SyntaxError: new.target can't come before a postfix operator."
     
    25152515  strict mode: "SyntaxError: new.target can't come before a postfix operator."
    25162516test/language/expressions/postfix-increment/target-cover-yieldexpr.js:
    2517   default: 'Test262: This statement should not be evaluated.'
    2518   strict mode: 'Test262: This statement should not be evaluated.'
     2517  default: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
     2518  strict mode: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
    25192519test/language/expressions/postfix-increment/target-newtarget.js:
    25202520  default: "SyntaxError: new.target can't come before a postfix operator."
     
    25382538  strict mode: "SyntaxError: new.target can't come after a prefix operator."
    25392539test/language/expressions/prefix-decrement/target-cover-yieldexpr.js:
    2540   default: 'Test262: This statement should not be evaluated.'
    2541   strict mode: 'Test262: This statement should not be evaluated.'
     2540  default: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
     2541  strict mode: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
    25422542test/language/expressions/prefix-decrement/target-newtarget.js:
    25432543  default: "SyntaxError: new.target can't come after a prefix operator."
     
    25612561  strict mode: "SyntaxError: new.target can't come after a prefix operator."
    25622562test/language/expressions/prefix-increment/target-cover-yieldexpr.js:
    2563   default: 'Test262: This statement should not be evaluated.'
    2564   strict mode: 'Test262: This statement should not be evaluated.'
     2563  default: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
     2564  strict mode: 'SyntaxError: Prefix -- operator applied to value that is not a reference.'
    25652565test/language/expressions/prefix-increment/target-newtarget.js:
    25662566  default: "SyntaxError: new.target can't come after a prefix operator."
     
    25702570  strict mode: 'Test262Error: did not perform ArgumentsListEvaluation Expected SameValue(«true», «false») to be true'
    25712571test/language/expressions/this/S11.1.1_A1.js:
    2572   default: 'Test262: This statement should not be evaluated.'
    2573   strict mode: 'Test262: This statement should not be evaluated.'
     2572  default: 'SyntaxError: Left side of assignment is not a reference.'
     2573  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    25742574test/language/expressions/yield/star-iterable.js:
    25752575  default: 'Test262Error: First result `done` flag Expected SameValue(«false», «undefined») to be true'
     
    27922792test/language/module-code/instn-once.js:
    27932793  module: "SyntaxError: Unexpected identifier 'as'. Expected 'from' before exported module name."
     2794test/language/module-code/instn-resolve-empty-export.js:
     2795  module: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
     2796test/language/module-code/instn-resolve-empty-import.js:
     2797  module: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
     2798test/language/module-code/instn-resolve-err-reference.js:
     2799  module: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
    27942800test/language/module-code/instn-resolve-order-depth.js:
    27952801  module: "SyntaxError: 'break' is only valid inside a switch or loop statement."
    27962802test/language/module-code/instn-resolve-order-src.js:
    2797   module: "SyntaxError: 'break' is only valid inside a switch or loop statement."
     2803  module: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
    27982804test/language/module-code/instn-star-as-props-dflt-skip.js:
    27992805  module: "SyntaxError: Unexpected identifier 'as'. Expected 'from' before exported module name."
     
    28152821  module: 'Test262: This statement should not be evaluated.'
    28162822test/language/module-code/parse-err-reference.js:
    2817   module: 'Test262: This statement should not be evaluated.'
     2823  module: 'SyntaxError: Postfix ++ operator applied to value that is not a reference.'
    28182824test/language/statements/class/class-name-ident-await-escaped.js:
    28192825  default: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
     
    31893195  default: 'Test262: This statement should not be evaluated.'
    31903196test/language/types/boolean/S8.3_A2.1.js:
    3191   default: 'Test262: This statement should not be evaluated.'
    3192   strict mode: 'Test262: This statement should not be evaluated.'
     3197  default: 'SyntaxError: Left side of assignment is not a reference.'
     3198  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    31933199test/language/types/boolean/S8.3_A2.2.js:
    3194   default: 'Test262: This statement should not be evaluated.'
    3195   strict mode: 'Test262: This statement should not be evaluated.'
     3200  default: 'SyntaxError: Left side of assignment is not a reference.'
     3201  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    31963202test/language/types/reference/S8.7.2_A1_T1.js:
    3197   default: 'Test262: This statement should not be evaluated.'
    3198   strict mode: 'Test262: This statement should not be evaluated.'
     3203  default: 'SyntaxError: Left side of assignment is not a reference.'
     3204  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    31993205test/language/types/reference/S8.7.2_A1_T2.js:
    3200   default: 'Test262: This statement should not be evaluated.'
    3201   strict mode: 'Test262: This statement should not be evaluated.'
     3206  default: 'SyntaxError: Left side of assignment is not a reference.'
     3207  strict mode: 'SyntaxError: Left side of assignment is not a reference.'
    32023208test/language/types/reference/put-value-prop-base-primitive-realm.js:
    32033209  default: 'Test262Error: number Expected SameValue(«0», «1») to be true'
  • trunk/LayoutTests/ChangeLog

    r245402 r245406  
     12019-05-16  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] Invalid AssignmentTargetType should be an early error.
     4        https://bugs.webkit.org/show_bug.cgi?id=197603
     5
     6        Reviewed by Keith Miller.
     7
     8        * fast/events/window-onerror4-expected.txt:
     9        * ietestcenter/Javascript/11.13.1-1-1-expected.txt:
     10        * ietestcenter/Javascript/11.13.1-1-2-expected.txt:
     11        * ietestcenter/Javascript/11.13.1-1-3-expected.txt:
     12        * ietestcenter/Javascript/11.13.1-1-4-expected.txt:
     13        * js/basic-strict-mode-expected.txt:
     14        * js/dom/assign-expected.txt:
     15        * js/dom/line-column-numbers-expected.txt:
     16        * js/dom/line-column-numbers.html:
     17        * js/dom/postfix-syntax-expected.txt:
     18        * js/dom/prefix-syntax-expected.txt:
     19        * js/dom/script-tests/line-column-numbers.js:
     20        * js/function-toString-parentheses-expected.txt:
     21        * js/parser-syntax-check-expected.txt:
     22        * js/parser-xml-close-comment-expected.txt:
     23        * js/script-tests/function-toString-parentheses.js:
     24        * js/script-tests/parser-syntax-check.js:
     25        Update tests & expectations to reflect new SyntaxErrors.
     26
     27        * js/script-tests/toString-prefix-postfix-preserve-parens.js:
     28        * js/toString-prefix-postfix-preserve-parens-expected.txt:
     29        None of the prefix/postfix tests make sense here now that they're all SyntaxErrors;
     30        remove them and just leave the typeof tests.
     31
    1322019-05-16  Youenn Fablet  <youenn@apple.com>
    233
  • trunk/LayoutTests/fast/events/window-onerror4-expected.txt

    r202023 r245406  
    11You should see a log record if window.onerror is working properly for this test.Bug 8519.
    22
    3 Error caught successfully: ReferenceError: Left side of assignment is not a reference. File: undefined Line: 1 Column: 3 Error: ReferenceError: Left side of assignment is not a reference.
     3Error caught successfully: SyntaxError: Left side of assignment is not a reference. File: window-onerror4.html Line: 16 Column: 9 Error: SyntaxError: Left side of assignment is not a reference.
    44
  • trunk/LayoutTests/ietestcenter/Javascript/11.13.1-1-1-expected.txt

    r62810 r245406  
    55
    66PASS ES5Harness.preconditionPassed is true
    7 PASS ES5Harness.testPassed is true
     7FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
    88PASS successfullyParsed is true
    99
  • trunk/LayoutTests/ietestcenter/Javascript/11.13.1-1-2-expected.txt

    r62810 r245406  
    55
    66PASS ES5Harness.preconditionPassed is true
    7 PASS ES5Harness.testPassed is true
     7FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
    88PASS successfullyParsed is true
    99
  • trunk/LayoutTests/ietestcenter/Javascript/11.13.1-1-3-expected.txt

    r62810 r245406  
    55
    66PASS ES5Harness.preconditionPassed is true
    7 PASS ES5Harness.testPassed is true
     7FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
    88PASS successfullyParsed is true
    99
  • trunk/LayoutTests/ietestcenter/Javascript/11.13.1-1-4-expected.txt

    r62810 r245406  
    55
    66PASS ES5Harness.preconditionPassed is true
    7 PASS ES5Harness.testPassed is true
     7FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
    88PASS successfullyParsed is true
    99
  • trunk/LayoutTests/js/basic-strict-mode-expected.txt

    r237259 r245406  
    134134PASS (function(){'use strict'; function f() { arguments-- }}) threw exception SyntaxError: 'arguments' cannot be modified in strict mode..
    135135PASS global.eval('"use strict"; if (0) ++arguments; true;') threw exception SyntaxError: Cannot modify 'arguments' in strict mode..
    136 PASS 'use strict'; ++(1, eval) threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
     136PASS 'use strict'; ++(1, eval) threw exception SyntaxError: Prefix ++ operator applied to value that is not a reference..
    137137PASS (function(){'use strict'; ++(1, eval)}) threw exception SyntaxError: Cannot modify 'eval' in strict mode..
    138 PASS 'use strict'; ++(1, 2, 3, eval) threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
     138PASS 'use strict'; ++(1, 2, 3, eval) threw exception SyntaxError: Prefix ++ operator applied to value that is not a reference..
    139139PASS (function(){'use strict'; ++(1, 2, 3, eval)}) threw exception SyntaxError: Cannot modify 'eval' in strict mode..
    140 PASS 'use strict'; (1, eval)++ threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
     140PASS 'use strict'; (1, eval)++ threw exception SyntaxError: Postfix ++ operator applied to value that is not a reference..
    141141PASS (function(){'use strict'; (1, eval)++}) threw exception SyntaxError: Cannot modify 'eval' in strict mode..
    142 PASS 'use strict'; --(1, eval) threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
     142PASS 'use strict'; --(1, eval) threw exception SyntaxError: Prefix -- operator applied to value that is not a reference..
    143143PASS (function(){'use strict'; --(1, eval)}) threw exception SyntaxError: Cannot modify 'eval' in strict mode..
    144 PASS 'use strict'; (1, eval)-- threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
     144PASS 'use strict'; (1, eval)-- threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
    145145PASS (function(){'use strict'; (1, eval)--}) threw exception SyntaxError: 'eval' cannot be modified in strict mode..
    146 PASS 'use strict'; (1, 2, 3, eval)-- threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
     146PASS 'use strict'; (1, 2, 3, eval)-- threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
    147147PASS (function(){'use strict'; (1, 2, 3, eval)--}) threw exception SyntaxError: 'eval' cannot be modified in strict mode..
    148148PASS 'use strict'; function f() { ++(1, arguments) } threw exception SyntaxError: Cannot modify 'arguments' in strict mode..
  • trunk/LayoutTests/js/dom/assign-expected.txt

    r158425 r245406  
    1414PASS ((window.x)) = 9; x is 9
    1515PASS ((window["x"])) = 10; x is 10
    16 PASS (y, x) = "FAIL"; threw exception ReferenceError: Left side of assignment is not a reference..
    17 PASS (true ? x : y) = "FAIL"; threw exception ReferenceError: Left side of assignment is not a reference..
     16PASS (y, x) = "FAIL"; threw exception SyntaxError: Left side of assignment is not a reference..
     17PASS (true ? x : y) = "FAIL"; threw exception SyntaxError: Left side of assignment is not a reference..
    1818PASS x++ = "FAIL"; threw exception SyntaxError: Left hand side of operator '=' must be a reference..
    1919PASS successfullyParsed is true
  • trunk/LayoutTests/js/dom/line-column-numbers-expected.txt

    r156066 r245406  
    139139
    140140--> Case 21 Stack Trace:
    141     0   toFuzz21 at line-column-numbers.html:206:26
    142     1   global code at line-column-numbers.html:209:13
     141    0   eval at [native code]
     142    1   global code at line-column-numbers.html:205:9
    143143
    144144--> Case 22 Stack Trace:
    145     0   toFuzz22 at line-column-numbers.html:220:36
    146     1   global code at line-column-numbers.html:224:13
     145    0   toFuzz22 at line-column-numbers.html:221:36
     146    1   global code at line-column-numbers.html:225:13
    147147
    148148--> Case 1 Stack Trace:
     
    281281
    282282--> Case 21 Stack Trace:
    283     0   toFuzz21b at line-column-numbers.js:141:26
    284     1   global code at line-column-numbers.js:144:14
     283    0   eval at [native code]
     284    1   global code at line-column-numbers.js:140:9
    285285
    286286--> Case 22 Stack Trace:
    287     0   toFuzz22b at line-column-numbers.js:153:36
    288     1   global code at line-column-numbers.js:157:14
     287    0   toFuzz22b at line-column-numbers.js:154:36
     288    1   global code at line-column-numbers.js:158:14
    289289
    290290PASS successfullyParsed is true
  • trunk/LayoutTests/js/dom/line-column-numbers.html

    r156066 r245406  
    203203<script>
    204204try {
    205     function toFuzz21() {
    206         if (PriorityQueue.prototype.doSort() instanceof (this ^= function() {
    207         })) return 2;
    208     }
    209     toFuzz21();
     205    eval(
     206        "function toFuzz21() {\n" +
     207        "    if (PriorityQueue.prototype.doSort() instanceof (this ^= function () {})) return 2;\n" +
     208        "}\n" +
     209        "toFuzz21();"
     210    );
    210211} catch(e) {
    211212    printStack(e.stack);
  • trunk/LayoutTests/js/dom/postfix-syntax-expected.txt

    r156066 r245406  
    1414PASS ((window.x))++ is 8
    1515PASS ((window["x"]))++ is 9
    16 PASS (y, x)++ threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
    17 PASS (true ? x : y)++ threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
     16PASS (y, x)++ threw exception SyntaxError: Postfix ++ operator applied to value that is not a reference..
     17PASS (true ? x : y)++ threw exception SyntaxError: Postfix ++ operator applied to value that is not a reference..
    1818PASS x++++ threw exception SyntaxError: Unexpected token '++'.
    1919PASS x is 0
  • trunk/LayoutTests/js/dom/prefix-syntax-expected.txt

    r156066 r245406  
    1414PASS ++((window.x)) is 9
    1515PASS ++((window["x"])) is 10
    16 PASS ++(y, x) threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
    17 PASS ++(true ? x : y) threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
    18 PASS ++++x threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
     16PASS ++(y, x) threw exception SyntaxError: Prefix ++ operator applied to value that is not a reference..
     17PASS ++(true ? x : y) threw exception SyntaxError: Prefix ++ operator applied to value that is not a reference..
     18PASS ++++x threw exception SyntaxError: The prefix-increment operator requires a reference expression..
    1919PASS successfullyParsed is true
    2020
  • trunk/LayoutTests/js/dom/script-tests/line-column-numbers.js

    r156066 r245406  
    138138testId++;
    139139try {
    140     function toFuzz21b() {
    141         if (PriorityQueue.prototype.doSort() instanceof (this ^= function() {
    142         })) return 2;
    143     }
    144     toFuzz21b();
     140    eval(
     141        "function toFuzz21() {\n" +
     142        "    if (PriorityQueue.prototype.doSort() instanceof (this ^= function () {})) return 2;\n" +
     143        "}\n" +
     144        "toFuzz21();"
     145    );
    145146} catch(e) {
    146147    printStack(e.stack);
  • trunk/LayoutTests/js/function-toString-parentheses-expected.txt

    r187012 r245406  
    218218PASS compileAndSerialize('a = (b + c)') is 'a = (b + c)'
    219219PASS compileAndSerialize('a + b = c') threw exception SyntaxError: Left hand side of operator '=' must be a reference..
    220 PASS compileAndSerialize('(a + b) = c') is '(a + b) = c'
     220PASS compileAndSerialize('(a + b) = c') threw exception SyntaxError: Left side of assignment is not a reference..
    221221PASS compileAndSerialize('a + (b = c)') is 'a + (b = c)'
    222222PASS compileAndSerialize('a *= b *= c') is 'a *= b *= c'
     
    230230PASS compileAndSerialize('a *= (b + c)') is 'a *= (b + c)'
    231231PASS compileAndSerialize('a + b *= c') threw exception SyntaxError: Left hand side of operator '*=' must be a reference..
    232 PASS compileAndSerialize('(a + b) *= c') is '(a + b) *= c'
     232PASS compileAndSerialize('(a + b) *= c') threw exception SyntaxError: Left side of assignment is not a reference..
    233233PASS compileAndSerialize('a + (b *= c)') is 'a + (b *= c)'
    234234PASS compileAndSerialize('a /= b /= c') is 'a /= b /= c'
     
    242242PASS compileAndSerialize('a /= (b + c)') is 'a /= (b + c)'
    243243PASS compileAndSerialize('a + b /= c') threw exception SyntaxError: Left hand side of operator '/=' must be a reference..
    244 PASS compileAndSerialize('(a + b) /= c') is '(a + b) /= c'
     244PASS compileAndSerialize('(a + b) /= c') threw exception SyntaxError: Left side of assignment is not a reference..
    245245PASS compileAndSerialize('a + (b /= c)') is 'a + (b /= c)'
    246246PASS compileAndSerialize('a %= b %= c') is 'a %= b %= c'
     
    254254PASS compileAndSerialize('a %= (b + c)') is 'a %= (b + c)'
    255255PASS compileAndSerialize('a + b %= c') threw exception SyntaxError: Left hand side of operator '%=' must be a reference..
    256 PASS compileAndSerialize('(a + b) %= c') is '(a + b) %= c'
     256PASS compileAndSerialize('(a + b) %= c') threw exception SyntaxError: Left side of assignment is not a reference..
    257257PASS compileAndSerialize('a + (b %= c)') is 'a + (b %= c)'
    258258PASS compileAndSerialize('a += b += c') is 'a += b += c'
     
    266266PASS compileAndSerialize('a += (b + c)') is 'a += (b + c)'
    267267PASS compileAndSerialize('a + b += c') threw exception SyntaxError: Left hand side of operator '+=' must be a reference..
    268 PASS compileAndSerialize('(a + b) += c') is '(a + b) += c'
     268PASS compileAndSerialize('(a + b) += c') threw exception SyntaxError: Left side of assignment is not a reference..
    269269PASS compileAndSerialize('a + (b += c)') is 'a + (b += c)'
    270270PASS compileAndSerialize('a -= b -= c') is 'a -= b -= c'
     
    278278PASS compileAndSerialize('a -= (b + c)') is 'a -= (b + c)'
    279279PASS compileAndSerialize('a + b -= c') threw exception SyntaxError: Left hand side of operator '-=' must be a reference..
    280 PASS compileAndSerialize('(a + b) -= c') is '(a + b) -= c'
     280PASS compileAndSerialize('(a + b) -= c') threw exception SyntaxError: Left side of assignment is not a reference..
    281281PASS compileAndSerialize('a + (b -= c)') is 'a + (b -= c)'
    282282PASS compileAndSerialize('a <<= b <<= c') is 'a <<= b <<= c'
     
    290290PASS compileAndSerialize('a <<= (b + c)') is 'a <<= (b + c)'
    291291PASS compileAndSerialize('a + b <<= c') threw exception SyntaxError: Left hand side of operator '<<=' must be a reference..
    292 PASS compileAndSerialize('(a + b) <<= c') is '(a + b) <<= c'
     292PASS compileAndSerialize('(a + b) <<= c') threw exception SyntaxError: Left side of assignment is not a reference..
    293293PASS compileAndSerialize('a + (b <<= c)') is 'a + (b <<= c)'
    294294PASS compileAndSerialize('a >>= b >>= c') is 'a >>= b >>= c'
     
    302302PASS compileAndSerialize('a >>= (b + c)') is 'a >>= (b + c)'
    303303PASS compileAndSerialize('a + b >>= c') threw exception SyntaxError: Left hand side of operator '>>=' must be a reference..
    304 PASS compileAndSerialize('(a + b) >>= c') is '(a + b) >>= c'
     304PASS compileAndSerialize('(a + b) >>= c') threw exception SyntaxError: Left side of assignment is not a reference..
    305305PASS compileAndSerialize('a + (b >>= c)') is 'a + (b >>= c)'
    306306PASS compileAndSerialize('a >>>= b >>>= c') is 'a >>>= b >>>= c'
     
    314314PASS compileAndSerialize('a >>>= (b + c)') is 'a >>>= (b + c)'
    315315PASS compileAndSerialize('a + b >>>= c') threw exception SyntaxError: Left hand side of operator '>>>=' must be a reference..
    316 PASS compileAndSerialize('(a + b) >>>= c') is '(a + b) >>>= c'
     316PASS compileAndSerialize('(a + b) >>>= c') threw exception SyntaxError: Left side of assignment is not a reference..
    317317PASS compileAndSerialize('a + (b >>>= c)') is 'a + (b >>>= c)'
    318318PASS compileAndSerialize('a &= b &= c') is 'a &= b &= c'
     
    326326PASS compileAndSerialize('a &= (b + c)') is 'a &= (b + c)'
    327327PASS compileAndSerialize('a + b &= c') threw exception SyntaxError: Left hand side of operator '&=' must be a reference..
    328 PASS compileAndSerialize('(a + b) &= c') is '(a + b) &= c'
     328PASS compileAndSerialize('(a + b) &= c') threw exception SyntaxError: Left side of assignment is not a reference..
    329329PASS compileAndSerialize('a + (b &= c)') is 'a + (b &= c)'
    330330PASS compileAndSerialize('a ^= b ^= c') is 'a ^= b ^= c'
     
    338338PASS compileAndSerialize('a ^= (b + c)') is 'a ^= (b + c)'
    339339PASS compileAndSerialize('a + b ^= c') threw exception SyntaxError: Left hand side of operator '^=' must be a reference..
    340 PASS compileAndSerialize('(a + b) ^= c') is '(a + b) ^= c'
     340PASS compileAndSerialize('(a + b) ^= c') threw exception SyntaxError: Left side of assignment is not a reference..
    341341PASS compileAndSerialize('a + (b ^= c)') is 'a + (b ^= c)'
    342342PASS compileAndSerialize('a |= b |= c') is 'a |= b |= c'
     
    350350PASS compileAndSerialize('a |= (b + c)') is 'a |= (b + c)'
    351351PASS compileAndSerialize('a + b |= c') threw exception SyntaxError: Left hand side of operator '|=' must be a reference..
    352 PASS compileAndSerialize('(a + b) |= c') is '(a + b) |= c'
     352PASS compileAndSerialize('(a + b) |= c') threw exception SyntaxError: Left side of assignment is not a reference..
    353353PASS compileAndSerialize('a + (b |= c)') is 'a + (b |= c)'
    354354PASS compileAndSerialize('delete a + b') is 'delete a + b'
     
    369369PASS compileAndSerialize('++a + b') is '++a + b'
    370370PASS compileAndSerialize('(++a) + b') is '(++a) + b'
    371 PASS compileAndSerialize('++(a + b)') is '++(a + b)'
     371PASS compileAndSerialize('++(a + b)') threw exception SyntaxError: Prefix ++ operator applied to value that is not a reference..
    372372PASS compileAndSerialize('!++a') is '!++a'
    373373PASS compileAndSerialize('!(++a)') is '!(++a)'
    374374PASS compileAndSerialize('--a + b') is '--a + b'
    375375PASS compileAndSerialize('(--a) + b') is '(--a) + b'
    376 PASS compileAndSerialize('--(a + b)') is '--(a + b)'
     376PASS compileAndSerialize('--(a + b)') threw exception SyntaxError: Prefix -- operator applied to value that is not a reference..
    377377PASS compileAndSerialize('!--a') is '!--a'
    378378PASS compileAndSerialize('!(--a)') is '!(--a)'
     
    399399PASS compileAndSerialize('!a++') is '!a++'
    400400PASS compileAndSerialize('!(a++)') is '!(a++)'
    401 PASS compileAndSerialize('(!a)++') is '(!a)++'
     401PASS compileAndSerialize('(!a)++') threw exception SyntaxError: Postfix ++ operator applied to value that is not a reference..
    402402PASS compileAndSerialize('!a--') is '!a--'
    403403PASS compileAndSerialize('!(a--)') is '!(a--)'
    404 PASS compileAndSerialize('(!a)--') is '(!a)--'
     404PASS compileAndSerialize('(!a)--') threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
    405405PASS compileAndSerialize('(-1)[a]') is '(-1)[a]'
    406406PASS compileAndSerialize('(-1)[a] = b') is '(-1)[a] = b'
     
    442442PASS compileAndSerialize('++(1).a') is '++(1).a'
    443443PASS compileAndSerialize('(1).a()') is '(1).a()'
    444 PASS compileAndSerialize('(-1) = a') is '(-1) = a'
    445 PASS compileAndSerialize('(- 0) = a') is '(- 0) = a'
    446 PASS compileAndSerialize('1 = a') is '1 = a'
    447 PASS compileAndSerialize('(-1) *= a') is '(-1) *= a'
    448 PASS compileAndSerialize('(- 0) *= a') is '(- 0) *= a'
    449 PASS compileAndSerialize('1 *= a') is '1 *= a'
    450 PASS compileAndSerialize('(-1) /= a') is '(-1) /= a'
    451 PASS compileAndSerialize('(- 0) /= a') is '(- 0) /= a'
    452 PASS compileAndSerialize('1 /= a') is '1 /= a'
    453 PASS compileAndSerialize('(-1) %= a') is '(-1) %= a'
    454 PASS compileAndSerialize('(- 0) %= a') is '(- 0) %= a'
    455 PASS compileAndSerialize('1 %= a') is '1 %= a'
    456 PASS compileAndSerialize('(-1) += a') is '(-1) += a'
    457 PASS compileAndSerialize('(- 0) += a') is '(- 0) += a'
    458 PASS compileAndSerialize('1 += a') is '1 += a'
    459 PASS compileAndSerialize('(-1) -= a') is '(-1) -= a'
    460 PASS compileAndSerialize('(- 0) -= a') is '(- 0) -= a'
    461 PASS compileAndSerialize('1 -= a') is '1 -= a'
    462 PASS compileAndSerialize('(-1) <<= a') is '(-1) <<= a'
    463 PASS compileAndSerialize('(- 0) <<= a') is '(- 0) <<= a'
    464 PASS compileAndSerialize('1 <<= a') is '1 <<= a'
    465 PASS compileAndSerialize('(-1) >>= a') is '(-1) >>= a'
    466 PASS compileAndSerialize('(- 0) >>= a') is '(- 0) >>= a'
    467 PASS compileAndSerialize('1 >>= a') is '1 >>= a'
    468 PASS compileAndSerialize('(-1) >>>= a') is '(-1) >>>= a'
    469 PASS compileAndSerialize('(- 0) >>>= a') is '(- 0) >>>= a'
    470 PASS compileAndSerialize('1 >>>= a') is '1 >>>= a'
    471 PASS compileAndSerialize('(-1) &= a') is '(-1) &= a'
    472 PASS compileAndSerialize('(- 0) &= a') is '(- 0) &= a'
    473 PASS compileAndSerialize('1 &= a') is '1 &= a'
    474 PASS compileAndSerialize('(-1) ^= a') is '(-1) ^= a'
    475 PASS compileAndSerialize('(- 0) ^= a') is '(- 0) ^= a'
    476 PASS compileAndSerialize('1 ^= a') is '1 ^= a'
    477 PASS compileAndSerialize('(-1) |= a') is '(-1) |= a'
    478 PASS compileAndSerialize('(- 0) |= a') is '(- 0) |= a'
    479 PASS compileAndSerialize('1 |= a') is '1 |= a'
     444PASS compileAndSerialize('(-1) = a') threw exception SyntaxError: Left side of assignment is not a reference..
     445PASS compileAndSerialize('(- 0) = a') threw exception SyntaxError: Left side of assignment is not a reference..
     446PASS compileAndSerialize('1 = a') threw exception SyntaxError: Left side of assignment is not a reference..
     447PASS compileAndSerialize('(-1) *= a') threw exception SyntaxError: Left side of assignment is not a reference..
     448PASS compileAndSerialize('(- 0) *= a') threw exception SyntaxError: Left side of assignment is not a reference..
     449PASS compileAndSerialize('1 *= a') threw exception SyntaxError: Left side of assignment is not a reference..
     450PASS compileAndSerialize('(-1) /= a') threw exception SyntaxError: Left side of assignment is not a reference..
     451PASS compileAndSerialize('(- 0) /= a') threw exception SyntaxError: Left side of assignment is not a reference..
     452PASS compileAndSerialize('1 /= a') threw exception SyntaxError: Left side of assignment is not a reference..
     453PASS compileAndSerialize('(-1) %= a') threw exception SyntaxError: Left side of assignment is not a reference..
     454PASS compileAndSerialize('(- 0) %= a') threw exception SyntaxError: Left side of assignment is not a reference..
     455PASS compileAndSerialize('1 %= a') threw exception SyntaxError: Left side of assignment is not a reference..
     456PASS compileAndSerialize('(-1) += a') threw exception SyntaxError: Left side of assignment is not a reference..
     457PASS compileAndSerialize('(- 0) += a') threw exception SyntaxError: Left side of assignment is not a reference..
     458PASS compileAndSerialize('1 += a') threw exception SyntaxError: Left side of assignment is not a reference..
     459PASS compileAndSerialize('(-1) -= a') threw exception SyntaxError: Left side of assignment is not a reference..
     460PASS compileAndSerialize('(- 0) -= a') threw exception SyntaxError: Left side of assignment is not a reference..
     461PASS compileAndSerialize('1 -= a') threw exception SyntaxError: Left side of assignment is not a reference..
     462PASS compileAndSerialize('(-1) <<= a') threw exception SyntaxError: Left side of assignment is not a reference..
     463PASS compileAndSerialize('(- 0) <<= a') threw exception SyntaxError: Left side of assignment is not a reference..
     464PASS compileAndSerialize('1 <<= a') threw exception SyntaxError: Left side of assignment is not a reference..
     465PASS compileAndSerialize('(-1) >>= a') threw exception SyntaxError: Left side of assignment is not a reference..
     466PASS compileAndSerialize('(- 0) >>= a') threw exception SyntaxError: Left side of assignment is not a reference..
     467PASS compileAndSerialize('1 >>= a') threw exception SyntaxError: Left side of assignment is not a reference..
     468PASS compileAndSerialize('(-1) >>>= a') threw exception SyntaxError: Left side of assignment is not a reference..
     469PASS compileAndSerialize('(- 0) >>>= a') threw exception SyntaxError: Left side of assignment is not a reference..
     470PASS compileAndSerialize('1 >>>= a') threw exception SyntaxError: Left side of assignment is not a reference..
     471PASS compileAndSerialize('(-1) &= a') threw exception SyntaxError: Left side of assignment is not a reference..
     472PASS compileAndSerialize('(- 0) &= a') threw exception SyntaxError: Left side of assignment is not a reference..
     473PASS compileAndSerialize('1 &= a') threw exception SyntaxError: Left side of assignment is not a reference..
     474PASS compileAndSerialize('(-1) ^= a') threw exception SyntaxError: Left side of assignment is not a reference..
     475PASS compileAndSerialize('(- 0) ^= a') threw exception SyntaxError: Left side of assignment is not a reference..
     476PASS compileAndSerialize('1 ^= a') threw exception SyntaxError: Left side of assignment is not a reference..
     477PASS compileAndSerialize('(-1) |= a') threw exception SyntaxError: Left side of assignment is not a reference..
     478PASS compileAndSerialize('(- 0) |= a') threw exception SyntaxError: Left side of assignment is not a reference..
     479PASS compileAndSerialize('1 |= a') threw exception SyntaxError: Left side of assignment is not a reference..
    480480PASS compileAndSerializeLeftmostTest('({ }).x') is '({ }).x'
    481481PASS compileAndSerializeLeftmostTest('x = { }') is 'x = { }'
  • trunk/LayoutTests/js/parser-syntax-check-expected.txt

    r220068 r245406  
    2525PASS Valid:   "new (-1)" with TypeError
    2626PASS Valid:   "function f() { new (-1) }"
    27 PASS Valid:   "a: b: c: new f(x++)++" with ReferenceError
    28 PASS Valid:   "function f() { a: b: c: new f(x++)++ }"
     27PASS Invalid: "a: b: c: new f(x++)++". Produced the following syntax error: "SyntaxError: Postfix ++ operator applied to value that is not a reference."
     28PASS Invalid: "function f() { a: b: c: new f(x++)++ }". Produced the following syntax error: "SyntaxError: Postfix ++ operator applied to value that is not a reference."
    2929PASS Valid:   "(a)++" with ReferenceError
    3030PASS Valid:   "function f() { (a)++ }"
    31 PASS Valid:   "(1--).x" with ReferenceError
    32 PASS Valid:   "function f() { (1--).x }"
     31PASS Invalid: "(1--).x". Produced the following syntax error: "SyntaxError: Postfix -- operator applied to value that is not a reference."
     32PASS Invalid: "function f() { (1--).x }". Produced the following syntax error: "SyntaxError: Postfix -- operator applied to value that is not a reference."
    3333PASS Invalid: "a-- ++". Produced the following syntax error: "SyntaxError: Unexpected token '++'"
    3434PASS Invalid: "function f() { a-- ++ }". Produced the following syntax error: "SyntaxError: Unexpected token '++'"
    3535PASS Invalid: "(a:) --b". Produced the following syntax error: "SyntaxError: Unexpected token ':'. Expected ')' to end a compound expression."
    3636PASS Invalid: "function f() { (a:) --b }". Produced the following syntax error: "SyntaxError: Unexpected token ':'. Expected ')' to end a compound expression."
    37 PASS Valid:   "++ -- ++ a" with ReferenceError
    38 PASS Valid:   "function f() { ++ -- ++ a }"
    39 PASS Valid:   "++ new new a ++" with ReferenceError
    40 PASS Valid:   "function f() { ++ new new a ++ }"
     37PASS Invalid: "++ -- ++ a". Produced the following syntax error: "SyntaxError: The prefix-increment operator requires a reference expression."
     38PASS Invalid: "function f() { ++ -- ++ a }". Produced the following syntax error: "SyntaxError: The prefix-increment operator requires a reference expression."
     39PASS Invalid: "++ new new a ++". Produced the following syntax error: "SyntaxError: Prefix ++ operator applied to value that is not a reference."
     40PASS Invalid: "function f() { ++ new new a ++ }". Produced the following syntax error: "SyntaxError: Prefix ++ operator applied to value that is not a reference."
    4141PASS Valid:   "delete void 0"
    4242PASS Valid:   "function f() { delete void 0 }"
     
    4545PASS Invalid: "(a++". Produced the following syntax error: "SyntaxError: Unexpected end of script"
    4646PASS Invalid: "function f() { (a++ }". Produced the following syntax error: "SyntaxError: Unexpected token '}'. Expected ')' to end a compound expression."
    47 PASS Valid:   "++a--" with ReferenceError
    48 PASS Valid:   "function f() { ++a-- }"
    49 PASS Valid:   "++((a))--" with ReferenceError
    50 PASS Valid:   "function f() { ++((a))-- }"
    51 PASS Valid:   "(a.x++)++" with ReferenceError
    52 PASS Valid:   "function f() { (a.x++)++ }"
     47PASS Invalid: "++a--". Produced the following syntax error: "SyntaxError: The increment operator requires a reference expression."
     48PASS Invalid: "function f() { ++a-- }". Produced the following syntax error: "SyntaxError: The increment operator requires a reference expression."
     49PASS Invalid: "++((a))--". Produced the following syntax error: "SyntaxError: The increment operator requires a reference expression."
     50PASS Invalid: "function f() { ++((a))-- }". Produced the following syntax error: "SyntaxError: The increment operator requires a reference expression."
     51PASS Invalid: "(a.x++)++". Produced the following syntax error: "SyntaxError: Postfix ++ operator applied to value that is not a reference."
     52PASS Invalid: "function f() { (a.x++)++ }". Produced the following syntax error: "SyntaxError: Postfix ++ operator applied to value that is not a reference."
    5353PASS Invalid: "1: null". Produced the following syntax error: "SyntaxError: Unexpected token ':'. Parse error."
    5454PASS Invalid: "function f() { 1: null }". Produced the following syntax error: "SyntaxError: Unexpected token ':'. Parse error."
     
    111111PASS Invalid: "- false = 3". Produced the following syntax error: "SyntaxError: Left hand side of operator '=' must be a reference."
    112112PASS Invalid: "function f() { - false = 3 }". Produced the following syntax error: "SyntaxError: Left hand side of operator '=' must be a reference."
    113 PASS Valid:   "a: b: c: (1 + null) = 3" with ReferenceError
    114 PASS Valid:   "function f() { a: b: c: (1 + null) = 3 }"
     113PASS Invalid: "a: b: c: (1 + null) = 3". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     114PASS Invalid: "function f() { a: b: c: (1 + null) = 3 }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    115115PASS Valid:   "a[2] = b.l += c /= 4 * 7 ^ !6" with ReferenceError
    116116PASS Valid:   "function f() { a[2] = b.l += c /= 4 * 7 ^ !6 }"
     
    119119PASS Invalid: "typeof a &= typeof b". Produced the following syntax error: "SyntaxError: Left hand side of operator '&=' must be a reference."
    120120PASS Invalid: "function f() { typeof a &= typeof b }". Produced the following syntax error: "SyntaxError: Left hand side of operator '&=' must be a reference."
    121 PASS Valid:   "a: ((typeof (a))) >>>= a || b.l && c" with ReferenceError
    122 PASS Valid:   "function f() { a: ((typeof (a))) >>>= a || b.l && c }"
     121PASS Invalid: "a: ((typeof (a))) >>>= a || b.l && c". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     122PASS Invalid: "function f() { a: ((typeof (a))) >>>= a || b.l && c }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    123123PASS Valid:   "a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g" with ReferenceError
    124124PASS Valid:   "function f() { a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g }"
     
    128128PASS Valid:   "a()()()" with ReferenceError
    129129PASS Valid:   "function f() { a()()() }"
    130 PASS Valid:   "s: l: a[2](4 == 6, 5 = 6)(f[4], 6)" with ReferenceError
    131 PASS Valid:   "function f() { s: l: a[2](4 == 6, 5 = 6)(f[4], 6) }"
     130PASS Invalid: "s: l: a[2](4 == 6, 5 = 6)(f[4], 6)". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     131PASS Invalid: "function f() { s: l: a[2](4 == 6, 5 = 6)(f[4], 6) }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    132132PASS Valid:   "s: eval(a.apply(), b.call(c[5] - f[7]))" with ReferenceError
    133133PASS Valid:   "function f() { s: eval(a.apply(), b.call(c[5] - f[7])) }"
     
    358358PASS Invalid: "const a, a, a = void 7 - typeof 8, a = 8". Produced the following syntax error: "SyntaxError: Unexpected token ','. const declared variable 'a' must have an initializer."
    359359PASS Invalid: "function f() { const a, a, a = void 7 - typeof 8, a = 8 }". Produced the following syntax error: "SyntaxError: Unexpected token ','. const declared variable 'a' must have an initializer."
    360 PASS Valid:   "const x_x = 6 /= 7 ? e : f" with ReferenceError
    361 PASS Valid:   "function f() { const x_x = 6 /= 7 ? e : f }"
     360PASS Invalid: "const x_x = 6 /= 7 ? e : f". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     361PASS Invalid: "function f() { const x_x = 6 /= 7 ? e : f }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    362362PASS Invalid: "var a = ?". Produced the following syntax error: "SyntaxError: Unexpected token '?'"
    363363PASS Invalid: "function f() { var a = ? }". Produced the following syntax error: "SyntaxError: Unexpected token '?'"
     
    505505PASS Valid:   "for (var a in b in c) break" with ReferenceError
    506506PASS Valid:   "function f() { for (var a in b in c) break }"
    507 PASS Valid:   "for (var a = 5 += 6 in b) break" with ReferenceError
    508 PASS Valid:   "function f() { for (var a = 5 += 6 in b) break }"
     507PASS Invalid: "for (var a = 5 += 6 in b) break". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     508PASS Invalid: "function f() { for (var a = 5 += 6 in b) break }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    509509PASS Valid:   "for (var a = foo('should be hit') in b) break" with ReferenceError
    510510PASS Valid:   "function f() { for (var a = foo('should be hit') in b) break }"
     
    525525PASS Invalid: "for (var (a) in b) { }". Produced the following syntax error: "SyntaxError: Unexpected token '('. Expected a parameter pattern or a ')' in parameter list."
    526526PASS Invalid: "function f() { for (var (a) in b) { } }". Produced the following syntax error: "SyntaxError: Unexpected token '('. Expected a parameter pattern or a ')' in parameter list."
    527 PASS Valid:   "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}" with ReferenceError
    528 PASS Valid:   "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
     527PASS Invalid: "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}". Produced the following syntax error: "SyntaxError: The decrement operator requires a reference expression."
     528PASS Invalid: "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }". Produced the following syntax error: "SyntaxError: The decrement operator requires a reference expression."
    529529PASS Invalid: "for (var {a} = 20 in b) { }". Produced the following syntax error: "SyntaxError: Cannot assign to the loop variable inside a for-in loop header."
    530530PASS Invalid: "function f() { for (var {a} = 20 in b) { } }". Produced the following syntax error: "SyntaxError: Cannot assign to the loop variable inside a for-in loop header."
     
    879879PASS Valid:   "if (0) new a(b+c).d = 5"
    880880PASS Valid:   "function f() { if (0) new a(b+c).d = 5 }"
    881 PASS Valid:   "if (0) new a(b+c) = 5"
    882 PASS Valid:   "function f() { if (0) new a(b+c) = 5 }"
     881PASS Invalid: "if (0) new a(b+c) = 5". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     882PASS Invalid: "function f() { if (0) new a(b+c) = 5 }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    883883PASS Valid:   "([1 || 1].a = 1)"
    884884PASS Valid:   "function f() { ([1 || 1].a = 1) }"
     
    10441044PASS Valid:   "({a:a}=1)()" with TypeError
    10451045PASS Valid:   "function f() { ({a:a}=1)() }"
    1046 PASS Valid:   "({a}=1)=1" with ReferenceError
    1047 PASS Valid:   "function f() { ({a}=1)=1 }"
    1048 PASS Valid:   "({a:a}=1)=1" with ReferenceError
    1049 PASS Valid:   "function f() { ({a:a}=1)=1 }"
    1050 PASS Valid:   "({a}=1=1)" with ReferenceError
    1051 PASS Valid:   "function f() { ({a}=1=1) }"
    1052 PASS Valid:   "({a:a}=1=1)" with ReferenceError
    1053 PASS Valid:   "function f() { ({a:a}=1=1) }"
     1046PASS Invalid: "({a}=1)=1". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1047PASS Invalid: "function f() { ({a}=1)=1 }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1048PASS Invalid: "({a:a}=1)=1". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1049PASS Invalid: "function f() { ({a:a}=1)=1 }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1050PASS Invalid: "({a}=1=1)". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1051PASS Invalid: "function f() { ({a}=1=1) }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1052PASS Invalid: "({a:a}=1=1)". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
     1053PASS Invalid: "function f() { ({a:a}=1=1) }". Produced the following syntax error: "SyntaxError: Left side of assignment is not a reference."
    10541054PASS Invalid: "var {x}". Produced the following syntax error: "SyntaxError: Unexpected end of script"
    10551055PASS Invalid: "function f() { var {x} }". Produced the following syntax error: "SyntaxError: Unexpected token '}'. Expected an initializer in destructuring variable declaration."
  • trunk/LayoutTests/js/parser-xml-close-comment-expected.txt

    r215235 r245406  
    44
    55
    6 PASS 'should be a syntax error' --> threw exception SyntaxError: Unexpected end of script.
    7 PASS /**/ 1--> threw exception SyntaxError: Unexpected end of script.
    8 PASS /**/ 1 --> threw exception SyntaxError: Unexpected end of script.
    9 PASS 1 /**/--> threw exception SyntaxError: Unexpected end of script.
    10 PASS 1 /**/ --> threw exception SyntaxError: Unexpected end of script.
     6PASS 'should be a syntax error' --> threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
     7PASS /**/ 1--> threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
     8PASS /**/ 1 --> threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
     9PASS 1 /**/--> threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
     10PASS 1 /**/ --> threw exception SyntaxError: Postfix -- operator applied to value that is not a reference..
    1111PASS 1/*
    1212*/--> is 1
  • trunk/LayoutTests/js/script-tests/function-toString-parentheses.js

    r187012 r245406  
    105105    testLowerFirst(op, "+");
    106106    shouldThrow("compileAndSerialize('a + b " + op + " c')");
    107     testKeepParentheses("(a + b) " + op + " c");
     107    shouldThrow("compileAndSerialize('(a + b) " + op + " c')");
    108108    testKeepParentheses("a + (b " + op + " c)");
    109109}
     
    116116    testKeepParentheses("" + op + "a + b");
    117117    testOptionalParentheses("(" + op + "a) + b");
    118     testKeepParentheses("" + op + "(a + b)");
     118    if (prefixOperators[i] !== "++" && prefixOperators[i] !== "--")
     119        testKeepParentheses("" + op + "(a + b)");
     120    else
     121        shouldThrow("compileAndSerialize('" + op + "(a + b)')");
    119122    testKeepParentheses("!" + op + "a");
    120123    testOptionalParentheses("!(" + op + "a)");
     
    124127testKeepParentheses("!a++");
    125128testOptionalParentheses("!(a++)");
    126 testKeepParentheses("(!a)++");
     129shouldThrow("compileAndSerialize('(!a)++')");
    127130
    128131testKeepParentheses("!a--");
    129132testOptionalParentheses("!(a--)");
    130 testKeepParentheses("(!a)--");
     133shouldThrow("compileAndSerialize('(!a)--')");
    131134
    132135testKeepParentheses("(-1)[a]");
     
    183186for (i = 0; i < assignmentOperators.length; ++i) {
    184187    var op = assignmentOperators[i];
    185     testKeepParentheses("(-1) " + op + " a");
    186     testKeepParentheses("(- 0) " + op + " a");
    187     testKeepParentheses("1 " + op + " a");
     188    shouldThrow("compileAndSerialize('(-1) " + op + " a')");
     189    shouldThrow("compileAndSerialize('(- 0) " + op + " a')");
     190    shouldThrow("compileAndSerialize('1 " + op + " a')");
    188191}
    189192
  • trunk/LayoutTests/js/script-tests/parser-syntax-check.js

    r220068 r245406  
    8484invalid("new -a");
    8585valid  ("new (-1)")
    86 valid  ("a: b: c: new f(x++)++")
     86invalid("a: b: c: new f(x++)++")
    8787valid  ("(a)++");
    88 valid  ("(1--).x");
     88invalid("(1--).x");
    8989invalid("a-- ++");
    9090invalid("(a:) --b");
    91 valid  ("++ -- ++ a");
    92 valid  ("++ new new a ++");
     91invalid("++ -- ++ a");
     92invalid("++ new new a ++");
    9393valid  ("delete void 0");
    9494invalid("delete the void");
    9595invalid("(a++");
    96 valid  ("++a--");
    97 valid  ("++((a))--");
    98 valid  ("(a.x++)++");
     96invalid("++a--");
     97invalid("++((a))--");
     98invalid("(a.x++)++");
    9999invalid("1: null");
    100100invalid("+-!~");
     
    132132valid  ("- - true % 5");
    133133invalid("- false = 3");
    134 valid  ("a: b: c: (1 + null) = 3");
     134invalid("a: b: c: (1 + null) = 3");
    135135valid  ("a[2] = b.l += c /= 4 * 7 ^ !6");
    136136invalid("a + typeof b += c in d");
    137137invalid("typeof a &= typeof b");
    138 valid  ("a: ((typeof (a))) >>>= a || b.l && c");
     138invalid("a: ((typeof (a))) >>>= a || b.l && c");
    139139valid  ("a: b: c[a /= f[a %= b]].l[c[x] = 7] -= a ? b <<= f : g");
    140140valid  ("-void+x['y'].l == x.l != 5 - f[7]");
     
    143143
    144144valid  ("a()()()");
    145 valid  ("s: l: a[2](4 == 6, 5 = 6)(f[4], 6)");
     145invalid("s: l: a[2](4 == 6, 5 = 6)(f[4], 6)");
    146146valid  ("s: eval(a.apply(), b.call(c[5] - f[7]))");
    147147invalid("a(");
     
    269269valid  ("const  a = void 7 - typeof 8, b = 8");
    270270invalid("const a, a, a = void 7 - typeof 8, a = 8");
    271 valid  ("const x_x = 6 /= 7 ? e : f");
     271invalid("const x_x = 6 /= 7 ? e : f");
    272272invalid("var a = ?");
    273273invalid("const a = *7");
     
    346346valid  ("for ((a ? b : c) in c) break");
    347347valid  ("for (var a in b in c) break");
    348 valid("for (var a = 5 += 6 in b) break");
     348invalid("for (var a = 5 += 6 in b) break");
    349349valid("for (var a = foo('should be hit') in b) break");
    350350invalid("for (var a += 5 in b) break");
     
    356356invalid("for (var a = (b in c in d) break");
    357357invalid("for (var (a) in b) { }");
    358 valid  ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
     358invalid("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
    359359invalid("for (var {a} = 20 in b) { }");
    360360invalid("for (var {a} = 20 of b) { }");
     
    544544valid("if (0) obj.foo\\u03bb; ")
    545545valid("if (0) new a(b+c).d = 5");
    546 valid("if (0) new a(b+c) = 5");
     546invalid("if (0) new a(b+c) = 5");
    547547valid("([1 || 1].a = 1)");
    548548valid("({a: 1 || 1}.a = 1)");
     
    632632valid("({a}=1)()")
    633633valid("({a:a}=1)()")
    634 valid("({a}=1)=1")
    635 valid("({a:a}=1)=1")
    636 valid("({a}=1=1)")
    637 valid("({a:a}=1=1)")
     634invalid("({a}=1)=1")
     635invalid("({a:a}=1)=1")
     636invalid("({a}=1=1)")
     637invalid("({a:a}=1=1)")
    638638invalid("var {x}")
    639639invalid("var {x, y}")
  • trunk/LayoutTests/js/script-tests/toString-prefix-postfix-preserve-parens.js

    r98407 r245406  
    11description(
    2 "This test checks that toString() round-trip on a function that has prefix, postfix and typeof operators applied to group expression will not remove the grouping. Also checks that evaluation of such a expression produces run-time exception"
     2"This test checks that toString() round-trip on a function that has a typeof operator applied to a group expression will not remove the grouping."
    33);
    4 
    5 function postfix_should_preserve_parens(x, y, z) {
    6     (x, y)++;
    7     return y;
    8 }
    9 
    10 function prefix_should_preserve_parens(x, y, z) {
    11     ++(x, y);
    12     return x;
    13 
    14 }
    15 
    16 function both_should_preserve_parens(x, y, z) {
    17     ++(x, y)--;
    18     return x;
    19 
    20 }
    21 
    22 function postfix_should_preserve_parens_multi(x, y, z) {
    23     (((x, y)))--;
    24     return x;
    25 }
    26 
    27 function prefix_should_preserve_parens_multi(x, y, z) {
    28     --(((x, y)));
    29     return x;
    30 }
    31 
    32 function both_should_preserve_parens_multi(x, y, z) {
    33     ++(((x, y)))--;
    34     return x;
    35 }
    36 
    37 function postfix_should_preserve_parens_multi1(x, y, z) {
    38     (((x)), y)--;
    39     return x;
    40 }
    41 
    42 function prefix_should_preserve_parens_multi1(x, y, z) {
    43     --(((x)), y);
    44     return x;
    45 }
    46 
    47 function prefix_should_preserve_parens_multi2(x, y, z) {
    48     var z = 0;
    49     --(((x), y), z);
    50     return x;
    51 }
    52 
    53 function postfix_should_preserve_parens_multi2(x, y, z) {
    54     var z = 0;
    55     (((x), y) ,z)++;
    56     return x;
    57 }
    584
    595// if these return a variable (such as y) instead of
     
    9238}
    9339
    94 function testToStringAndRTFailure(fn)
    95 {
    96     testToString(fn);
    97 
    98     // check that function call produces run-time exception
    99     shouldThrow(""+fn+ "(1, 2, 3);");
    100 
    101     // check that function call produces run-time exception after eval(unevalf)
    102     shouldThrow("eval(unevalf("+fn+ "))(1, 2, 3);");
    103 }
    104 
    10540function testToStringAndReturn(fn, p1, p2, retval)
    10641{
     
    11550}
    11651
    117 
    118 testToStringAndRTFailure("prefix_should_preserve_parens");
    119 testToStringAndRTFailure("postfix_should_preserve_parens");
    120 testToStringAndRTFailure("both_should_preserve_parens");
    121 testToStringAndRTFailure("prefix_should_preserve_parens_multi");
    122 testToStringAndRTFailure("postfix_should_preserve_parens_multi");
    123 testToStringAndRTFailure("prefix_should_preserve_parens_multi1");
    124 testToStringAndRTFailure("postfix_should_preserve_parens_multi1");
    125 testToStringAndRTFailure("prefix_should_preserve_parens_multi2");
    126 testToStringAndRTFailure("postfix_should_preserve_parens_multi2");
    127 
    12852testToStringAndReturn("typeof_should_preserve_parens", "'a'", 1, "'number'");
    12953testToStringAndReturn("typeof_should_preserve_parens1", "'a'", 1, "'number'");
  • trunk/LayoutTests/js/toString-prefix-postfix-preserve-parens-expected.txt

    r33979 r245406  
    1 This test checks that toString() round-trip on a function that has prefix, postfix and typeof operators applied to group expression will not remove the grouping. Also checks that evaluation of such a expression produces run-time exception
     1This test checks that toString() round-trip on a function that has a typeof operator applied to a group expression will not remove the grouping.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    55
    6 PASS unevalf(eval(unevalf(prefix_should_preserve_parens))) is unevalf(prefix_should_preserve_parens)
    7 PASS /.*\(+x\)*, y\)/.test(unevalf(prefix_should_preserve_parens)) is true
    8 PASS prefix_should_preserve_parens(1, 2, 3); threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
    9 PASS eval(unevalf(prefix_should_preserve_parens))(1, 2, 3); threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
    10 PASS unevalf(eval(unevalf(postfix_should_preserve_parens))) is unevalf(postfix_should_preserve_parens)
    11 PASS /.*\(+x\)*, y\)/.test(unevalf(postfix_should_preserve_parens)) is true
    12 PASS postfix_should_preserve_parens(1, 2, 3); threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
    13 PASS eval(unevalf(postfix_should_preserve_parens))(1, 2, 3); threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
    14 PASS unevalf(eval(unevalf(both_should_preserve_parens))) is unevalf(both_should_preserve_parens)
    15 PASS /.*\(+x\)*, y\)/.test(unevalf(both_should_preserve_parens)) is true
    16 PASS both_should_preserve_parens(1, 2, 3); threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
    17 PASS eval(unevalf(both_should_preserve_parens))(1, 2, 3); threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
    18 PASS unevalf(eval(unevalf(prefix_should_preserve_parens_multi))) is unevalf(prefix_should_preserve_parens_multi)
    19 PASS /.*\(+x\)*, y\)/.test(unevalf(prefix_should_preserve_parens_multi)) is true
    20 PASS prefix_should_preserve_parens_multi(1, 2, 3); threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
    21 PASS eval(unevalf(prefix_should_preserve_parens_multi))(1, 2, 3); threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
    22 PASS unevalf(eval(unevalf(postfix_should_preserve_parens_multi))) is unevalf(postfix_should_preserve_parens_multi)
    23 PASS /.*\(+x\)*, y\)/.test(unevalf(postfix_should_preserve_parens_multi)) is true
    24 PASS postfix_should_preserve_parens_multi(1, 2, 3); threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
    25 PASS eval(unevalf(postfix_should_preserve_parens_multi))(1, 2, 3); threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
    26 PASS unevalf(eval(unevalf(prefix_should_preserve_parens_multi1))) is unevalf(prefix_should_preserve_parens_multi1)
    27 PASS /.*\(+x\)*, y\)/.test(unevalf(prefix_should_preserve_parens_multi1)) is true
    28 PASS prefix_should_preserve_parens_multi1(1, 2, 3); threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
    29 PASS eval(unevalf(prefix_should_preserve_parens_multi1))(1, 2, 3); threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
    30 PASS unevalf(eval(unevalf(postfix_should_preserve_parens_multi1))) is unevalf(postfix_should_preserve_parens_multi1)
    31 PASS /.*\(+x\)*, y\)/.test(unevalf(postfix_should_preserve_parens_multi1)) is true
    32 PASS postfix_should_preserve_parens_multi1(1, 2, 3); threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
    33 PASS eval(unevalf(postfix_should_preserve_parens_multi1))(1, 2, 3); threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
    34 PASS unevalf(eval(unevalf(prefix_should_preserve_parens_multi2))) is unevalf(prefix_should_preserve_parens_multi2)
    35 PASS /.*\(+x\)*, y\)/.test(unevalf(prefix_should_preserve_parens_multi2)) is true
    36 PASS prefix_should_preserve_parens_multi2(1, 2, 3); threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
    37 PASS eval(unevalf(prefix_should_preserve_parens_multi2))(1, 2, 3); threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
    38 PASS unevalf(eval(unevalf(postfix_should_preserve_parens_multi2))) is unevalf(postfix_should_preserve_parens_multi2)
    39 PASS /.*\(+x\)*, y\)/.test(unevalf(postfix_should_preserve_parens_multi2)) is true
    40 PASS postfix_should_preserve_parens_multi2(1, 2, 3); threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
    41 PASS eval(unevalf(postfix_should_preserve_parens_multi2))(1, 2, 3); threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
    426PASS unevalf(eval(unevalf(typeof_should_preserve_parens))) is unevalf(typeof_should_preserve_parens)
    437PASS /.*\(+x\)*, y\)/.test(unevalf(typeof_should_preserve_parens)) is true
  • trunk/Source/JavaScriptCore/ChangeLog

    r245341 r245406  
     12019-05-16  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] Invalid AssignmentTargetType should be an early error.
     4        https://bugs.webkit.org/show_bug.cgi?id=197603
     5
     6        Reviewed by Keith Miller.
     7
     8        Since ES6, expressions like 0++, ++0, 0 = 0, and 0 += 0 are all specified as early errors:
     9          https://tc39.github.io/ecma262/#sec-update-expressions-static-semantics-early-errors
     10          https://tc39.github.io/ecma262/#sec-assignment-operators-static-semantics-early-errors
     11
     12        We currently throw late ReferenceErrors for these -- let's turn them into early SyntaxErrors.
     13        (This is based on the expectation that https://github.com/tc39/ecma262/pull/1527 will be accepted;
     14        if that doesn't come to pass, we can subsequently introduce early ReferenceError and revise these.)
     15
     16        * bytecompiler/NodesCodegen.cpp:
     17        (JSC::PostfixNode::emitBytecode): Add an assert for "function call LHS" case.
     18        (JSC::PrefixNode::emitBytecode): Add an assert for "function call LHS" case.
     19
     20        * parser/ASTBuilder.h:
     21        (JSC::ASTBuilder::isLocation): Added.
     22        (JSC::ASTBuilder::isAssignmentLocation): Fix misleading parameter name.
     23        (JSC::ASTBuilder::isFunctionCall): Added.
     24        (JSC::ASTBuilder::makeAssignNode): Add an assert for "function call LHS" case.
     25        * parser/SyntaxChecker.h:
     26        (JSC::SyntaxChecker::isLocation): Added.
     27        (JSC::SyntaxChecker::isAssignmentLocation): Fix incorrect definition and align with ASTBuilder.
     28        (JSC::SyntaxChecker::isFunctionCall): Added.
     29        * parser/Nodes.h:
     30        (JSC::ExpressionNode::isFunctionCall const): Added.
     31        Ensure that the parser can check whether an expression node is a function call.
     32
     33        * parser/Parser.cpp:
     34        (JSC::Parser<LexerType>::isSimpleAssignmentTarget): Added.
     35        (JSC::Parser<LexerType>::parseAssignmentExpression):
     36        (JSC::Parser<LexerType>::parseUnaryExpression): See below.
     37        * parser/Parser.h:
     38        Throw SyntaxError whenever an assignment or update expression's target is invalid.
     39        Unfortunately, it seems that web compatibility obliges us to exempt the "function call LHS" case in sloppy mode.
     40        (https://github.com/tc39/ecma262/issues/257#issuecomment-195106880)
     41
     42        Additional cleanup items:
     43          - Make use of `semanticFailIfTrue` for `isMetaProperty` checks, as it's equivalent.
     44          - Rename `requiresLExpr` to `hasPrefixUpdateOp` since it's now confusing,
     45            and get rid of `modifiesExpr` since it refers to the exact same condition.
     46          - Stop setting `lastOperator` near the end -- one case was incorrect and regardless neither is used.
     47
    1482019-05-15  Saam Barati  <sbarati@apple.com>
    249
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r244915 r245406  
    16671667        return emitDot(generator, dst);
    16681668
     1669    ASSERT(m_expr->isFunctionCall());
    16691670    return emitThrowReferenceError(generator, m_operator == OpPlusPlus
    16701671        ? "Postfix ++ operator applied to value that is not a reference."_s
     
    18801881        return emitDot(generator, dst);
    18811882
     1883    ASSERT(m_expr->isFunctionCall());
    18821884    return emitThrowReferenceError(generator, m_operator == OpPlusPlus
    18831885        ? "Prefix ++ operator applied to value that is not a reference."_s
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r245288 r245406  
    628628    }
    629629
    630     bool isAssignmentLocation(const Expression& pattern)
    631     {
    632         return pattern->isAssignmentLocation();
     630    bool isLocation(const Expression& node)
     631    {
     632        return node->isLocation();
     633    }
     634
     635    bool isAssignmentLocation(const Expression& node)
     636    {
     637        return node->isAssignmentLocation();
    633638    }
    634639
     
    646651    {
    647652        return isObjectLiteral(node) || isArrayLiteral(node);
     653    }
     654
     655    bool isFunctionCall(const Expression& node)
     656    {
     657        return node->isFunctionCall();
    648658    }
    649659
     
    14681478ExpressionNode* ASTBuilder::makeAssignNode(const JSTokenLocation& location, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
    14691479{
    1470     if (!loc->isLocation())
     1480    if (!loc->isLocation()) {
     1481        ASSERT(loc->isFunctionCall());
    14711482        return new (m_parserArena) AssignErrorNode(location, divot, start, end);
     1483    }
    14721484
    14731485    if (loc->isResolveNode()) {
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r245288 r245406  
    205205        virtual bool isBytecodeIntrinsicNode() const { return false; }
    206206        virtual bool isBinaryOpNode() const { return false; }
     207        virtual bool isFunctionCall() const { return false; }
    207208
    208209        virtual void emitBytecodeInConditionContext(BytecodeGenerator&, Label&, Label&, FallThroughMode);
     
    870871        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
    871872
     873        bool isFunctionCall() const override { return true; }
     874
    872875        ArgumentsNode* m_args;
    873876    };
     
    879882    private:
    880883        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
     884
     885        bool isFunctionCall() const override { return true; }
    881886
    882887        ExpressionNode* m_expr;
     
    891896        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
    892897
     898        bool isFunctionCall() const override { return true; }
     899
    893900        const Identifier& m_ident;
    894901        ArgumentsNode* m_args;
     
    901908    private:
    902909        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
     910
     911        bool isFunctionCall() const override { return true; }
    903912
    904913        ExpressionNode* m_base;
     
    916925
    917926    protected:
     927        bool isFunctionCall() const override { return true; }
     928
    918929        ExpressionNode* m_base;
    919930        const Identifier& m_ident;
     
    945956    private:
    946957        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
     958
     959        bool isFunctionCall() const override { return m_type == Type::Function; }
    947960
    948961        EmitterType m_emitter;
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r245152 r245406  
    36323632    return "error";
    36333633}
     3634
     3635template <typename LexerType>
     3636template <typename TreeBuilder> bool Parser<LexerType>::isSimpleAssignmentTarget(TreeBuilder& context, TreeExpression expr)
     3637{
     3638    // Web compatibility concerns prevent us from handling a function call LHS as an early error in sloppy mode.
     3639    // This behavior is currently unspecified, but see: https://github.com/tc39/ecma262/issues/257#issuecomment-195106880
     3640    return context.isLocation(expr) || (!strictMode() && context.isFunctionCall(expr));
     3641}
    36343642   
    36353643template <typename LexerType>
     
    37383746        m_parserState.nonTrivialExpressionCount++;
    37393747        hadAssignment = true;
    3740         if (UNLIKELY(context.isMetaProperty(lhs)))
    3741             internalFailWithMessage(false, metaPropertyName(context, lhs), " can't be the left hand side of an assignment expression");
     3748        semanticFailIfTrue(context.isMetaProperty(lhs), metaPropertyName(context, lhs), " can't be the left hand side of an assignment expression");
     3749        semanticFailIfFalse(isSimpleAssignmentTarget(context, lhs), "Left side of assignment is not a reference");
    37423750        context.assignmentStackAppend(assignmentStack, lhs, start, tokenStartPosition(), m_parserState.assignmentCount, op);
    37433751        start = tokenStartPosition();
     
    49304938    AllowInOverride allowInOverride(this);
    49314939    int tokenStackDepth = 0;
    4932     bool modifiesExpr = false;
    4933     bool requiresLExpr = false;
     4940    bool hasPrefixUpdateOp = false;
    49344941    unsigned lastOperator = 0;
    49354942
     
    49404947
    49414948    while (isUnaryOp(m_token.m_type)) {
    4942         if (strictMode()) {
    4943             switch (m_token.m_type) {
    4944             case PLUSPLUS:
    4945             case MINUSMINUS:
    4946             case AUTOPLUSPLUS:
    4947             case AUTOMINUSMINUS:
    4948                 semanticFailIfTrue(requiresLExpr, "The ", operatorString(true, lastOperator), " operator requires a reference expression");
    4949                 modifiesExpr = true;
    4950                 requiresLExpr = true;
    4951                 break;
    4952             default:
    4953                 semanticFailIfTrue(requiresLExpr, "The ", operatorString(true, lastOperator), " operator requires a reference expression");
    4954                 break;
    4955             }
     4949        switch (m_token.m_type) {
     4950        case PLUSPLUS:
     4951        case MINUSMINUS:
     4952        case AUTOPLUSPLUS:
     4953        case AUTOMINUSMINUS:
     4954            semanticFailIfTrue(hasPrefixUpdateOp, "The ", operatorString(true, lastOperator), " operator requires a reference expression");
     4955            hasPrefixUpdateOp = true;
     4956            break;
     4957        default:
     4958            semanticFailIfTrue(hasPrefixUpdateOp, "The ", operatorString(true, lastOperator), " operator requires a reference expression");
     4959            break;
    49564960        }
    49574961        lastOperator = m_token.m_type;
     
    49694973        failWithMessage("Cannot parse member expression");
    49704974    }
    4971     if (UNLIKELY(isUpdateOp(static_cast<JSTokenType>(lastOperator)) && context.isMetaProperty(expr)))
    4972         internalFailWithMessage(false, metaPropertyName(context, expr), " can't come after a prefix operator");
     4975    if (isUpdateOp(static_cast<JSTokenType>(lastOperator))) {
     4976        semanticFailIfTrue(context.isMetaProperty(expr), metaPropertyName(context, expr), " can't come after a prefix operator");
     4977        semanticFailIfFalse(isSimpleAssignmentTarget(context, expr), "Prefix ", lastOperator == PLUSPLUS ? "++" : "--", " operator applied to value that is not a reference");
     4978    }
    49734979    bool isEvalOrArguments = false;
    49744980    if (strictMode()) {
     
    49764982            isEvalOrArguments = *m_parserState.lastIdentifier == m_vm->propertyNames->eval || *m_parserState.lastIdentifier == m_vm->propertyNames->arguments;
    49774983    }
    4978     failIfTrueIfStrict(isEvalOrArguments && modifiesExpr, "Cannot modify '", m_parserState.lastIdentifier->impl(), "' in strict mode");
     4984    failIfTrueIfStrict(isEvalOrArguments && hasPrefixUpdateOp, "Cannot modify '", m_parserState.lastIdentifier->impl(), "' in strict mode");
    49794985    switch (m_token.m_type) {
    49804986    case PLUSPLUS:
    4981         if (UNLIKELY(context.isMetaProperty(expr)))
    4982             internalFailWithMessage(false, metaPropertyName(context, expr), " can't come before a postfix operator");
     4987        semanticFailIfTrue(context.isMetaProperty(expr), metaPropertyName(context, expr), " can't come before a postfix operator");
     4988        semanticFailIfFalse(isSimpleAssignmentTarget(context, expr), "Postfix ++ operator applied to value that is not a reference");
    49834989        m_parserState.nonTrivialExpressionCount++;
    49844990        m_parserState.nonLHSCount++;
     
    49864992        m_parserState.assignmentCount++;
    49874993        failIfTrueIfStrict(isEvalOrArguments, "Cannot modify '", m_parserState.lastIdentifier->impl(), "' in strict mode");
    4988         semanticFailIfTrue(requiresLExpr, "The ", operatorString(false, lastOperator), " operator requires a reference expression");
    4989         lastOperator = PLUSPLUS;
     4994        semanticFailIfTrue(hasPrefixUpdateOp, "The ", operatorString(false, lastOperator), " operator requires a reference expression");
    49904995        next();
    49914996        break;
    49924997    case MINUSMINUS:
    4993         if (UNLIKELY(context.isMetaProperty(expr)))
    4994             internalFailWithMessage(false, metaPropertyName(context, expr), " can't come before a postfix operator");
     4998        semanticFailIfTrue(context.isMetaProperty(expr), metaPropertyName(context, expr), " can't come before a postfix operator");
     4999        semanticFailIfFalse(isSimpleAssignmentTarget(context, expr), "Postfix -- operator applied to value that is not a reference");
    49955000        m_parserState.nonTrivialExpressionCount++;
    49965001        m_parserState.nonLHSCount++;
     
    49985003        m_parserState.assignmentCount++;
    49995004        failIfTrueIfStrict(isEvalOrArguments, "'", m_parserState.lastIdentifier->impl(), "' cannot be modified in strict mode");
    5000         semanticFailIfTrue(requiresLExpr, "The ", operatorString(false, lastOperator), " operator requires a reference expression");
    5001         lastOperator = PLUSPLUS;
     5005        semanticFailIfTrue(hasPrefixUpdateOp, "The ", operatorString(false, lastOperator), " operator requires a reference expression");
    50025006        next();
    50035007        break;
     
    50075011   
    50085012    JSTextPosition end = lastTokenEndPosition();
    5009 
    5010     if (!TreeBuilder::CreatesAST && (!strictMode()))
    5011         return expr;
    5012 
    50135013    while (tokenStackDepth) {
    50145014        switch (context.unaryTokenStackLastType(tokenStackDepth)) {
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r244038 r245406  
    16661666    template <class TreeBuilder> NEVER_INLINE const char* metaPropertyName(TreeBuilder&, TreeExpression);
    16671667
     1668    template <class TreeBuilder> ALWAYS_INLINE bool isSimpleAssignmentTarget(TreeBuilder&, TreeExpression);
     1669
    16681670    ALWAYS_INLINE int isBinaryOperator(JSTokenType);
    16691671    bool allowAutomaticSemicolon();
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r229608 r245406  
    394394    }
    395395
     396    bool isLocation(ExpressionType type)
     397    {
     398        return type == ResolveExpr || type == DotExpr || type == BracketExpr;
     399    }
     400
    396401    bool isAssignmentLocation(ExpressionType type)
    397402    {
    398         return type == ResolveExpr || type == DotExpr || type == BracketExpr;
     403        return isLocation(type) || type == DestructuringAssignment;
    399404    }
    400405
     
    412417    {
    413418        return isObjectLiteral(type) || isArrayLiteral(type);
     419    }
     420
     421    bool isFunctionCall(ExpressionType type)
     422    {
     423        return type == CallExpr;
    414424    }
    415425
Note: See TracChangeset for help on using the changeset viewer.