Title: [206590] trunk
Revision
206590
Author
sbar...@apple.com
Date
2016-09-29 11:03:23 -0700 (Thu, 29 Sep 2016)

Log Message

We don't properly propagate non-simple-parameter-list when parsing a setter
https://bugs.webkit.org/show_bug.cgi?id=160483

Reviewed by Joseph Pecoraro.

JSTests:

* test262.yaml:

Source/_javascript_Core:

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseFunctionParameters):

LayoutTests:

* js/parser-syntax-check-expected.txt:
* js/script-tests/parser-syntax-check.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (206589 => 206590)


--- trunk/JSTests/ChangeLog	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/JSTests/ChangeLog	2016-09-29 18:03:23 UTC (rev 206590)
@@ -1,3 +1,12 @@
+2016-09-29  Saam Barati  <sbar...@apple.com>
+
+        We don't properly propagate non-simple-parameter-list when parsing a setter
+        https://bugs.webkit.org/show_bug.cgi?id=160483
+
+        Reviewed by Joseph Pecoraro.
+
+        * test262.yaml:
+
 2016-09-28  Saam Barati  <sbar...@apple.com>
 
         stringProtoFuncRepeatCharacter will return `null` when it should not

Modified: trunk/JSTests/test262.yaml (206589 => 206590)


--- trunk/JSTests/test262.yaml	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/JSTests/test262.yaml	2016-09-29 18:03:23 UTC (rev 206590)
@@ -66726,9 +66726,9 @@
 - path: test262/test/language/expressions/object/method-definition/params-trailing-comma.js
   cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/expressions/object/method-definition/use-strict-with-non-simple-param.js
   cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
 - path: test262/test/language/expressions/object/method-definition/use-strict-with-non-simple-param.js

Modified: trunk/LayoutTests/ChangeLog (206589 => 206590)


--- trunk/LayoutTests/ChangeLog	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/LayoutTests/ChangeLog	2016-09-29 18:03:23 UTC (rev 206590)
@@ -1,3 +1,13 @@
+2016-09-29  Saam Barati  <sbar...@apple.com>
+
+        We don't properly propagate non-simple-parameter-list when parsing a setter
+        https://bugs.webkit.org/show_bug.cgi?id=160483
+
+        Reviewed by Joseph Pecoraro.
+
+        * js/parser-syntax-check-expected.txt:
+        * js/script-tests/parser-syntax-check.js:
+
 2016-09-29  Nan Wang  <n_w...@apple.com>
 
         AX: Meter: [Mac] Content in label element should be used as AXTitle or AXDescription

Modified: trunk/LayoutTests/js/parser-syntax-check-expected.txt (206589 => 206590)


--- trunk/LayoutTests/js/parser-syntax-check-expected.txt	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/LayoutTests/js/parser-syntax-check-expected.txt	2016-09-29 18:03:23 UTC (rev 206590)
@@ -1039,6 +1039,40 @@
 PASS Valid:   "function f() { ({set [x](x){}}) }"
 PASS Invalid: "({set [x (x){}})"
 PASS Invalid: "function f() { ({set [x (x){}}) }"
+PASS Valid:   "({set foo(x) { } })"
+PASS Valid:   "function f() { ({set foo(x) { } }) }"
+PASS Valid:   "({set foo(x) { 'use strict'; } })"
+PASS Valid:   "function f() { ({set foo(x) { 'use strict'; } }) }"
+PASS Invalid: "({set foo(x = 20) { 'use strict'; } })"
+PASS Invalid: "function f() { ({set foo(x = 20) { 'use strict'; } }) }"
+PASS Invalid: "({set foo({x}) { 'use strict'; } })"
+PASS Invalid: "function f() { ({set foo({x}) { 'use strict'; } }) }"
+PASS Invalid: "({set foo([x]) { 'use strict'; } })"
+PASS Invalid: "function f() { ({set foo([x]) { 'use strict'; } }) }"
+PASS Invalid: "({set foo(...x) {} })"
+PASS Invalid: "function f() { ({set foo(...x) {} }) }"
+PASS Valid:   "class Foo { set v(z) { } }"
+PASS Valid:   "function f() { class Foo { set v(z) { } } }"
+PASS Valid:   "class Foo { set v(z) { 'use strict'; } }"
+PASS Valid:   "function f() { class Foo { set v(z) { 'use strict'; } } }"
+PASS Invalid: "class Foo { set v(z = 50) { 'use strict'; } }"
+PASS Invalid: "function f() { class Foo { set v(z = 50) { 'use strict'; } } }"
+PASS Invalid: "class Foo { set v({z}) { 'use strict'; } }"
+PASS Invalid: "function f() { class Foo { set v({z}) { 'use strict'; } } }"
+PASS Invalid: "class Foo { set v([z]) { 'use strict'; } }"
+PASS Invalid: "function f() { class Foo { set v([z]) { 'use strict'; } } }"
+PASS Invalid: "class Foo { set v(...z) { } }"
+PASS Invalid: "function f() { class Foo { set v(...z) { } } }"
+PASS Invalid: "class foo { set y([x, y, x]) { } }"
+PASS Invalid: "function f() { class foo { set y([x, y, x]) { } } }"
+PASS Invalid: "class foo { set y([x, y, {x}]) { } }"
+PASS Invalid: "function f() { class foo { set y([x, y, {x}]) { } } }"
+PASS Invalid: "class foo { set y({x, x}) { } }"
+PASS Invalid: "function f() { class foo { set y({x, x}) { } } }"
+PASS Invalid: "class foo { set y({x, field: {x}}) { } }"
+PASS Invalid: "function f() { class foo { set y({x, field: {x}}) { } } }"
+PASS Valid:   "class foo { set y({x, field: {xx}}) { } }"
+PASS Valid:   "function f() { class foo { set y({x, field: {xx}}) { } } }"
 PASS Invalid: "({[...x]: 1})"
 PASS Invalid: "function f() { ({[...x]: 1}) }"
 PASS Invalid: "function f({a, a}) {}"

Modified: trunk/LayoutTests/js/script-tests/parser-syntax-check.js (206589 => 206590)


--- trunk/LayoutTests/js/script-tests/parser-syntax-check.js	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/LayoutTests/js/script-tests/parser-syntax-check.js	2016-09-29 18:03:23 UTC (rev 206590)
@@ -629,6 +629,23 @@
 invalid("({set [x](){}})")
 valid("({set [x](x){}})")
 invalid("({set [x (x){}})")
+valid("({set foo(x) { } })");
+valid("({set foo(x) { 'use strict'; } })");
+invalid("({set foo(x = 20) { 'use strict'; } })");
+invalid("({set foo({x}) { 'use strict'; } })");
+invalid("({set foo([x]) { 'use strict'; } })");
+invalid("({set foo(...x) {} })");
+valid("class Foo { set v(z) { } }");
+valid("class Foo { set v(z) { 'use strict'; } }");
+invalid("class Foo { set v(z = 50) { 'use strict'; } }");
+invalid("class Foo { set v({z}) { 'use strict'; } }");
+invalid("class Foo { set v([z]) { 'use strict'; } }");
+invalid("class Foo { set v(...z) { } }");
+invalid("class foo { set y([x, y, x]) { } }");
+invalid("class foo { set y([x, y, {x}]) { } }");
+invalid("class foo { set y({x, x}) { } }");
+invalid("class foo { set y({x, field: {x}}) { } }");
+valid("class foo { set y({x, field: {xx}}) { } }");
 invalid("({[...x]: 1})")
 invalid("function f({a, a}) {}");
 invalid("function f({a}, a) {}");

Modified: trunk/Source/_javascript_Core/ChangeLog (206589 => 206590)


--- trunk/Source/_javascript_Core/ChangeLog	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-09-29 18:03:23 UTC (rev 206590)
@@ -1,3 +1,13 @@
+2016-09-29  Saam Barati  <sbar...@apple.com>
+
+        We don't properly propagate non-simple-parameter-list when parsing a setter
+        https://bugs.webkit.org/show_bug.cgi?id=160483
+
+        Reviewed by Joseph Pecoraro.
+
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseFunctionParameters):
+
 2016-09-28  Saam Barati  <sbar...@apple.com>
 
         stringProtoFuncRepeatCharacter will return `null` when it should not

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (206589 => 206590)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2016-09-29 17:53:42 UTC (rev 206589)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2016-09-29 18:03:23 UTC (rev 206590)
@@ -1994,11 +1994,15 @@
     } else if (mode == SourceParseMode::SetterMode) {
         failIfTrue(match(CLOSEPAREN), "setter functions must have one parameter");
         const Identifier* duplicateParameter = nullptr;
-        auto parameter = parseDestructuringPattern(context, DestructuringKind::DestructureToParameters, ExportType::NotExported, &duplicateParameter);
+        bool hasDestructuringPattern = false;
+        auto parameter = parseDestructuringPattern(context, DestructuringKind::DestructureToParameters, ExportType::NotExported, &duplicateParameter, &hasDestructuringPattern);
         failIfFalse(parameter, "setter functions must have one parameter");
         auto defaultValue = parseDefaultValueForDestructuringPattern(context);
         propagateError();
-        semanticFailIfTrue(duplicateParameter && defaultValue, "Duplicate parameter '", duplicateParameter->impl(), "' not allowed in function with default parameter values");
+        if (defaultValue || hasDestructuringPattern) {
+            semanticFailIfTrue(duplicateParameter, "Duplicate parameter '", duplicateParameter->impl(), "' not allowed in function with non-simple parameter list");
+            currentScope()->setHasNonSimpleParameterList();
+        }
         context.appendParameter(parameterList, parameter, defaultValue);
         functionInfo.parameterCount = 1;
         functionInfo.functionLength = defaultValue ? 0 : 1;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to