Changeset 201725 in webkit


Ignore:
Timestamp:
Jun 6, 2016 1:33:39 PM (8 years ago)
Author:
gskachkov@gmail.com
Message:

Source/JavaScriptCore:
[ESNext] Trailing commas in function parameters.
https://bugs.webkit.org/show_bug.cgi?id=158020

Reviewed by Keith Miller.

ESNext allow to add trailing commas in function parameters and function arguments.
Link to spec - https://jeffmo.github.io/es-trailing-function-commas
Example of using - (function (a, b,) { return a + b; })(1,2,);

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFormalParameters):
(JSC::Parser<LexerType>::parseArguments):

  • tests/stress/trailing-comma-in-function-paramters.js: Added.

LayoutTests:
[ESNext] Support trailing commas in function param lists
https://bugs.webkit.org/show_bug.cgi?id=158020

Reviewed by Keith Miller.

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
  • sputnik/Conformance/13_Function_Definition/S13_A5.html:
Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201724 r201725  
     12016-06-06  Skachkov Oleksandr  <gskachkov@gmail.com>
     2
     3        [ESNext] Support trailing commas in function param lists
     4        https://bugs.webkit.org/show_bug.cgi?id=158020
     5
     6        Reviewed by Keith Miller.
     7
     8        * js/parser-syntax-check-expected.txt:
     9        * js/script-tests/parser-syntax-check.js:
     10        * sputnik/Conformance/13_Function_Definition/S13_A5.html:
     11
    1122016-06-06  George Ruan  <gruan@apple.com>
    213
  • trunk/LayoutTests/js/parser-syntax-check-expected.txt

    r201566 r201725  
    138138PASS Invalid: "a(5,"
    139139PASS Invalid: "function f() { a(5, }"
    140 PASS Invalid: "a(5,)"
    141 PASS Invalid: "function f() { a(5,) }"
     140PASS Valid:   "a(5,)" with ReferenceError
     141PASS Valid:  "function f() { a(5,) }"
    142142PASS Invalid: "a(5,6"
    143143PASS Invalid: "function f() { a(5,6 }"
     
    173173PASS Invalid: "function f(a b) {}"
    174174PASS Invalid: "function f() { function f(a b) {} }"
    175 PASS Invalid: "function f(a,) {}"
    176 PASS Invalid: "function f() { function f(a,) {} }"
     175PASS Valid:  "function f(a,) {}"
     176PASS Valid:  "function f() { function f(a,) {} }"
    177177PASS Invalid: "function f(a,"
    178178PASS Invalid: "function f() { function f(a, }"
  • trunk/LayoutTests/js/script-tests/parser-syntax-check.js

    r201566 r201725  
    148148invalid("a(5");
    149149invalid("a(5,");
    150 invalid("a(5,)");
     150valid("a(5,)");
    151151invalid("a(5,6");
    152152valid  ("a(b[7], c <d> e.l, new a() > b)");
     
    168168invalid("function () {}");
    169169invalid("function f(a b) {}");
    170 invalid("function f(a,) {}");
     170valid("function f(a,) {}");
    171171invalid("function f(a,");
    172172invalid("function f(a, 1) {}");
  • trunk/LayoutTests/sputnik/Conformance/13_Function_Definition/S13_A5.html

    r201566 r201725  
    101101//CHECK#3
    102102try{
    103         eval("function __func(arg1, arg2, arg3,){return arguments.length;}");
    104         testFailed('#3: eval("function __func(arg1, arg2, arg3,){return arguments.length;}") lead to throwing exception')
     103        eval("function __func(arg1, arg2, arg3,,){return arguments.length;}");
     104        testFailed('#3: eval("function __func(arg1, arg2, arg3,,){return arguments.length;}") lead to throwing exception')
    105105} catch(e){
    106106        if(!(e instanceof SyntaxError)){
    107                 testFailed('#3.1: eval("function __func(arg1, arg2, arg3,){return arguments.length;}") lead to throwing exception of SyntaxError. Actual: exception is '+e);
     107                testFailed('#3.1: eval("function __func(arg1, arg2, arg3,,){return arguments.length;}") lead to throwing exception of SyntaxError. Actual: exception is '+e);
    108108        }
    109109}
  • trunk/Source/JavaScriptCore/ChangeLog

    r201719 r201725  
     12016-06-06  Skachkov Oleksandr  <gskachkov@gmail.com>
     2        [ESNext] Trailing commas in function parameters.
     3        https://bugs.webkit.org/show_bug.cgi?id=158020
     4
     5        Reviewed by Keith Miller.
     6
     7        ESNext allow to add trailing commas in function parameters and function arguments.
     8        Link to spec - https://jeffmo.github.io/es-trailing-function-commas
     9        Example of using - (function (a, b,) { return a + b; })(1,2,);
     10
     11        * parser/Parser.cpp:
     12        (JSC::Parser<LexerType>::parseFormalParameters):
     13        (JSC::Parser<LexerType>::parseArguments):
     14        * tests/stress/trailing-comma-in-function-paramters.js: Added.
     15
    1162016-06-05  Gavin & Ellie Barraclough  <barraclough@apple.com>
    217
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r201624 r201725  
    17471747        TreeExpression defaultValue = 0;
    17481748
     1749        if (UNLIKELY(match(CLOSEPAREN)))
     1750            break;
     1751       
    17491752        if (match(DOTDOTDOT)) {
    17501753            next();
     
    38273830        next(TreeBuilder::DontBuildStrings);
    38283831
     3832        if (UNLIKELY(match(CLOSEPAREN)))
     3833            break;
     3834       
    38293835        TreeExpression arg = parseArgument(context, argType);
    38303836        propagateError();
Note: See TracChangeset for help on using the changeset viewer.