Changeset 206590 in webkit


Ignore:
Timestamp:
Sep 29, 2016, 11:03:23 AM (9 years ago)
Author:
sbarati@apple.com
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/JavaScriptCore:

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFunctionParameters):

LayoutTests:

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r206573 r206590  
     12016-09-29  Saam Barati  <sbarati@apple.com>
     2
     3        We don't properly propagate non-simple-parameter-list when parsing a setter
     4        https://bugs.webkit.org/show_bug.cgi?id=160483
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * test262.yaml:
     9
    1102016-09-28  Saam Barati  <sbarati@apple.com>
    211
  • trunk/JSTests/test262.yaml

    r206353 r206590  
    6672766727  cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
    6672866728- path: test262/test/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js
    66729   cmd: runTest262 :fail, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
     66729  cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
    6673066730- path: test262/test/language/expressions/object/method-definition/setter-use-strict-with-non-simple-param.js
    66731   cmd: runTest262 :fail, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
     66731  cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
    6673266732- path: test262/test/language/expressions/object/method-definition/use-strict-with-non-simple-param.js
    6673366733  cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
  • trunk/LayoutTests/ChangeLog

    r206581 r206590  
     12016-09-29  Saam Barati  <sbarati@apple.com>
     2
     3        We don't properly propagate non-simple-parameter-list when parsing a setter
     4        https://bugs.webkit.org/show_bug.cgi?id=160483
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * js/parser-syntax-check-expected.txt:
     9        * js/script-tests/parser-syntax-check.js:
     10
    1112016-09-29  Nan Wang  <n_wang@apple.com>
    212
  • trunk/LayoutTests/js/parser-syntax-check-expected.txt

    r204895 r206590  
    10401040PASS Invalid: "({set [x (x){}})"
    10411041PASS Invalid: "function f() { ({set [x (x){}}) }"
     1042PASS Valid:   "({set foo(x) { } })"
     1043PASS Valid:   "function f() { ({set foo(x) { } }) }"
     1044PASS Valid:   "({set foo(x) { 'use strict'; } })"
     1045PASS Valid:   "function f() { ({set foo(x) { 'use strict'; } }) }"
     1046PASS Invalid: "({set foo(x = 20) { 'use strict'; } })"
     1047PASS Invalid: "function f() { ({set foo(x = 20) { 'use strict'; } }) }"
     1048PASS Invalid: "({set foo({x}) { 'use strict'; } })"
     1049PASS Invalid: "function f() { ({set foo({x}) { 'use strict'; } }) }"
     1050PASS Invalid: "({set foo([x]) { 'use strict'; } })"
     1051PASS Invalid: "function f() { ({set foo([x]) { 'use strict'; } }) }"
     1052PASS Invalid: "({set foo(...x) {} })"
     1053PASS Invalid: "function f() { ({set foo(...x) {} }) }"
     1054PASS Valid:   "class Foo { set v(z) { } }"
     1055PASS Valid:   "function f() { class Foo { set v(z) { } } }"
     1056PASS Valid:   "class Foo { set v(z) { 'use strict'; } }"
     1057PASS Valid:   "function f() { class Foo { set v(z) { 'use strict'; } } }"
     1058PASS Invalid: "class Foo { set v(z = 50) { 'use strict'; } }"
     1059PASS Invalid: "function f() { class Foo { set v(z = 50) { 'use strict'; } } }"
     1060PASS Invalid: "class Foo { set v({z}) { 'use strict'; } }"
     1061PASS Invalid: "function f() { class Foo { set v({z}) { 'use strict'; } } }"
     1062PASS Invalid: "class Foo { set v([z]) { 'use strict'; } }"
     1063PASS Invalid: "function f() { class Foo { set v([z]) { 'use strict'; } } }"
     1064PASS Invalid: "class Foo { set v(...z) { } }"
     1065PASS Invalid: "function f() { class Foo { set v(...z) { } } }"
     1066PASS Invalid: "class foo { set y([x, y, x]) { } }"
     1067PASS Invalid: "function f() { class foo { set y([x, y, x]) { } } }"
     1068PASS Invalid: "class foo { set y([x, y, {x}]) { } }"
     1069PASS Invalid: "function f() { class foo { set y([x, y, {x}]) { } } }"
     1070PASS Invalid: "class foo { set y({x, x}) { } }"
     1071PASS Invalid: "function f() { class foo { set y({x, x}) { } } }"
     1072PASS Invalid: "class foo { set y({x, field: {x}}) { } }"
     1073PASS Invalid: "function f() { class foo { set y({x, field: {x}}) { } } }"
     1074PASS Valid:   "class foo { set y({x, field: {xx}}) { } }"
     1075PASS Valid:   "function f() { class foo { set y({x, field: {xx}}) { } } }"
    10421076PASS Invalid: "({[...x]: 1})"
    10431077PASS Invalid: "function f() { ({[...x]: 1}) }"
  • trunk/LayoutTests/js/script-tests/parser-syntax-check.js

    r204895 r206590  
    630630valid("({set [x](x){}})")
    631631invalid("({set [x (x){}})")
     632valid("({set foo(x) { } })");
     633valid("({set foo(x) { 'use strict'; } })");
     634invalid("({set foo(x = 20) { 'use strict'; } })");
     635invalid("({set foo({x}) { 'use strict'; } })");
     636invalid("({set foo([x]) { 'use strict'; } })");
     637invalid("({set foo(...x) {} })");
     638valid("class Foo { set v(z) { } }");
     639valid("class Foo { set v(z) { 'use strict'; } }");
     640invalid("class Foo { set v(z = 50) { 'use strict'; } }");
     641invalid("class Foo { set v({z}) { 'use strict'; } }");
     642invalid("class Foo { set v([z]) { 'use strict'; } }");
     643invalid("class Foo { set v(...z) { } }");
     644invalid("class foo { set y([x, y, x]) { } }");
     645invalid("class foo { set y([x, y, {x}]) { } }");
     646invalid("class foo { set y({x, x}) { } }");
     647invalid("class foo { set y({x, field: {x}}) { } }");
     648valid("class foo { set y({x, field: {xx}}) { } }");
    632649invalid("({[...x]: 1})")
    633650invalid("function f({a, a}) {}");
  • trunk/Source/JavaScriptCore/ChangeLog

    r206573 r206590  
     12016-09-29  Saam Barati  <sbarati@apple.com>
     2
     3        We don't properly propagate non-simple-parameter-list when parsing a setter
     4        https://bugs.webkit.org/show_bug.cgi?id=160483
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * parser/Parser.cpp:
     9        (JSC::Parser<LexerType>::parseFunctionParameters):
     10
    1112016-09-28  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r206333 r206590  
    19951995        failIfTrue(match(CLOSEPAREN), "setter functions must have one parameter");
    19961996        const Identifier* duplicateParameter = nullptr;
    1997         auto parameter = parseDestructuringPattern(context, DestructuringKind::DestructureToParameters, ExportType::NotExported, &duplicateParameter);
     1997        bool hasDestructuringPattern = false;
     1998        auto parameter = parseDestructuringPattern(context, DestructuringKind::DestructureToParameters, ExportType::NotExported, &duplicateParameter, &hasDestructuringPattern);
    19981999        failIfFalse(parameter, "setter functions must have one parameter");
    19992000        auto defaultValue = parseDefaultValueForDestructuringPattern(context);
    20002001        propagateError();
    2001         semanticFailIfTrue(duplicateParameter && defaultValue, "Duplicate parameter '", duplicateParameter->impl(), "' not allowed in function with default parameter values");
     2002        if (defaultValue || hasDestructuringPattern) {
     2003            semanticFailIfTrue(duplicateParameter, "Duplicate parameter '", duplicateParameter->impl(), "' not allowed in function with non-simple parameter list");
     2004            currentScope()->setHasNonSimpleParameterList();
     2005        }
    20022006        context.appendParameter(parameterList, parameter, defaultValue);
    20032007        functionInfo.parameterCount = 1;
Note: See TracChangeset for help on using the changeset viewer.