[JSC] Support optional catch binding
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jul 2017 16:15:32 +0000 (16:15 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jul 2017 16:15:32 +0000 (16:15 +0000)
commit9a07e2756da4e4893fc54a2e16b572f2dcb0cbc3
tree3fd6d6122dea60ecde5b0eea918d8ba176b09b07
parent050decd1175109c452f162bd745bac0533aacfea
[JSC] Support optional catch binding
https://bugs.webkit.org/show_bug.cgi?id=174981

Reviewed by Saam Barati.

JSTests:

* stress/optional-catch-binding-syntax.js: Added.
(testSyntax):
(testSyntaxError):
(catch.catch):
* stress/optional-catch-binding.js: Added.
(shouldBe):
(throwException):

Source/JavaScriptCore:

This patch implements optional catch binding proposal[1], which is now stage 3.
This proposal adds a new `catch` brace with no error value binding.

    ```
        try {
            ...
        } catch {
            ...
        }
    ```

Sometimes we do not need to get error value actually. For example, the function returns
boolean which means whether the function succeeds.

    ```
    function parse(result) // -> bool
    {
         try {
             parseInner(result);
         } catch {
             return false;
         }
         return true;
    }
    ```

In the above case, we are not interested in the actual error value. Without this syntax,
we always need to introduce a binding for an error value that is just ignored.

[1]: https://michaelficarra.github.io/optional-catch-binding-proposal/

* bytecompiler/NodesCodegen.cpp:
(JSC::TryNode::emitBytecode):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseTryStatement):

LayoutTests:

Rebaseline existing tests.

* js/parser-syntax-check-expected.txt:
* js/script-tests/parser-syntax-check.js:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T4-expected.txt:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T4.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220068 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/stress/optional-catch-binding-syntax.js [new file with mode: 0644]
JSTests/stress/optional-catch-binding.js [new file with mode: 0644]
LayoutTests/ChangeLog
LayoutTests/js/parser-syntax-check-expected.txt
LayoutTests/js/script-tests/parser-syntax-check.js
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T4-expected.txt
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T4.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/parser/Parser.cpp