Title: [268688] trunk
Revision
268688
Author
[email protected]
Date
2020-10-19 14:14:04 -0700 (Mon, 19 Oct 2020)

Log Message

test262: test/language/expressions/conditional/in-branch-1.js
https://bugs.webkit.org/show_bug.cgi?id=217879

Patch by Mark Cohen <[email protected]> on 2020-10-19
Reviewed by Darin Adler.

JSTests:

I fixed this test262 failure - see the JSC ChangeLog for more details.
All I've done in this directory is remove the expected failure from
test262/expectations.yaml.

* test262/expectations.yaml:

Source/_javascript_Core:

The test262 test in question checks that the parser respects the +In
parameter on the left-hand AssignmentExpression (between `?` and `:`)
in the ternary operator grammar. The relevant piece of the spec can be
found here (https://tc39.es/ecma262/#sec-conditional-operator). The
test checks this by embedding a ternary with left-hand
AssignmentExpression that contains the `in` keyword in the
initializing statement of a `for` loop, where `in` would normally be
disallowed. All this patch does is unconditionally allow the `in`
keyword inside the left-hand AssignmentExpression of a ternary.

This also fixes a variable typo in parseForStatement.

* parser/Parser.cpp:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (268687 => 268688)


--- trunk/JSTests/ChangeLog	2020-10-19 21:12:43 UTC (rev 268687)
+++ trunk/JSTests/ChangeLog	2020-10-19 21:14:04 UTC (rev 268688)
@@ -1,3 +1,16 @@
+2020-10-19  Mark Cohen  <[email protected]>
+
+        test262: test/language/expressions/conditional/in-branch-1.js
+        https://bugs.webkit.org/show_bug.cgi?id=217879
+
+        Reviewed by Darin Adler.
+
+        I fixed this test262 failure - see the JSC ChangeLog for more details.
+        All I've done in this directory is remove the expected failure from
+        test262/expectations.yaml.
+
+        * test262/expectations.yaml:
+
 2020-10-18  Caio Lima  <[email protected]>
 
         [ESNext][JIT] Add support for UntypedUse on PutPrivateName's base operand

Modified: trunk/JSTests/test262/expectations.yaml (268687 => 268688)


--- trunk/JSTests/test262/expectations.yaml	2020-10-19 21:12:43 UTC (rev 268687)
+++ trunk/JSTests/test262/expectations.yaml	2020-10-19 21:14:04 UTC (rev 268688)
@@ -2375,9 +2375,6 @@
 test/language/expressions/compound-assignment/S11.13.2_A7.9_T4.js:
   default: 'Test262Error: Expected true but got false'
   strict mode: 'Test262Error: Expected true but got false'
-test/language/expressions/conditional/in-branch-1.js:
-  default: "SyntaxError: Unexpected keyword 'in'. Expected ':' in ternary operator."
-  strict mode: "SyntaxError: Unexpected keyword 'in'. Expected ':' in ternary operator."
 test/language/expressions/dynamic-import/catch/nested-async-gen-await-eval-script-code-target.js:
   module: 'Test262:AsyncTestFailure:Test262Error: [object Object]'
 test/language/expressions/dynamic-import/catch/nested-async-gen-return-await-eval-script-code-target.js:

Modified: trunk/Source/_javascript_Core/ChangeLog (268687 => 268688)


--- trunk/Source/_javascript_Core/ChangeLog	2020-10-19 21:12:43 UTC (rev 268687)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-10-19 21:14:04 UTC (rev 268688)
@@ -1,3 +1,24 @@
+2020-10-19  Mark Cohen  <[email protected]>
+
+        test262: test/language/expressions/conditional/in-branch-1.js
+        https://bugs.webkit.org/show_bug.cgi?id=217879
+
+        Reviewed by Darin Adler.
+
+        The test262 test in question checks that the parser respects the +In
+        parameter on the left-hand AssignmentExpression (between `?` and `:`)
+        in the ternary operator grammar. The relevant piece of the spec can be
+        found here (https://tc39.es/ecma262/#sec-conditional-operator). The
+        test checks this by embedding a ternary with left-hand
+        AssignmentExpression that contains the `in` keyword in the
+        initializing statement of a `for` loop, where `in` would normally be
+        disallowed. All this patch does is unconditionally allow the `in`
+        keyword inside the left-hand AssignmentExpression of a ternary.
+
+        This also fixes a variable typo in parseForStatement.
+
+        * parser/Parser.cpp:
+
 2020-10-18  David Kilzer  <[email protected]>
 
         Fix -Wdeprecated-copy warnings in WTF and _javascript_Core

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (268687 => 268688)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2020-10-19 21:12:43 UTC (rev 268687)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2020-10-19 21:14:04 UTC (rev 268688)
@@ -1343,7 +1343,7 @@
     JSTextPosition declsEnd;
     TreeExpression decls = 0;
     TreeDestructuringPattern pattern = 0;
-    bool isVarDeclaraton = match(VAR);
+    bool isVarDeclaration = match(VAR);
     bool isLetDeclaration = match(LET);
     bool isConstDeclaration = match(CONSTTOKEN);
     bool forLoopConstDoesNotHaveInitializer = false;
@@ -1365,7 +1365,7 @@
             popScope(lexicalScope, TreeBuilder::NeedsFreeVariableInfo);
     };
 
-    if (isVarDeclaraton || isLetDeclaration || isConstDeclaration) {
+    if (isVarDeclaration || isLetDeclaration || isConstDeclaration) {
         /*
          for (var/let/const IDENT in/of _expression_) statement
          for (var/let/const varDeclarationList; expressionOpt; expressionOpt)
@@ -1383,7 +1383,7 @@
         JSTextPosition initStart;
         JSTextPosition initEnd;
         DeclarationType declarationType;
-        if (isVarDeclaraton)
+        if (isVarDeclaration)
             declarationType = DeclarationType::VarDeclaration;
         else if (isLetDeclaration)
             declarationType = DeclarationType::LetDeclaration;
@@ -1447,7 +1447,7 @@
             result = context.createForOfLoop(isAwaitFor, location, forInTarget, expr, statement, declLocation, declsStart, inLocation, exprEnd, startLine, endLine, *lexicalVariables);
         else {
             ASSERT(!isAwaitFor);
-            if (isVarDeclaraton && forInInitializer)
+            if (isVarDeclaration && forInInitializer)
                 result = context.createForInLoop(location, decls, expr, statement, declLocation, declsStart, inLocation, exprEnd, startLine, endLine, *lexicalVariables);
             else
                 result = context.createForInLoop(location, forInTarget, expr, statement, declLocation, declsStart, inLocation, exprEnd, startLine, endLine, *lexicalVariables);
@@ -4026,7 +4026,12 @@
     m_parserState.nonTrivialExpressionCount++;
     m_parserState.nonLHSCount++;
     next(TreeBuilder::DontBuildStrings);
-    TreeExpression lhs = parseAssignmentExpression(context);
+    TreeExpression lhs = 0;
+    {
+        // this block is necessary so that we don't leave `in` enabled for the rhs
+        AllowInOverride allowInOverride(this);
+        lhs = parseAssignmentExpression(context);
+    }
     failIfFalse(lhs, "Cannot parse left hand side of ternary operator");
     context.setEndOffset(lhs, m_lastTokenEndPosition.offset);
     consumeOrFailWithFlags(COLON, TreeBuilder::DontBuildStrings, "Expected ':' in ternary operator");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to