Bug 152575 - [ES6] Arrow function syntax. Lexical bind "super" inside of the arrow function in generator.
Summary: [ES6] Arrow function syntax. Lexical bind "super" inside of the arrow functio...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 145132
Blocks: 140855
  Show dependency treegraph
 
Reported: 2015-12-28 10:15 PST by GSkachkov
Modified: 2016-03-04 11:19 PST (History)
6 users (show)

See Also:


Attachments
Patch (7.90 KB, patch)
2016-03-02 23:59 PST, GSkachkov
ysuzuki: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description GSkachkov 2015-12-28 10:15:06 PST
We need support following case in lexical bind arguments in arrow function:

class B {
    gen() {
        return 42;
    }
}

class A extends B {
    *gen() {
        let arr = () => super.gen();
        return arr();
    }
}

typeof a.gen().next() === 'array';
Comment 1 GSkachkov 2016-03-02 23:50:42 PST
We are already supporting arguments in arrow function in generators.
Modified test example:

var result = 'some-value';
class B {
    gen() {
        return result;
    }
}

class A extends B {
    *gen() {
        let arr = () => super.gen();
        return arr();
    }
}

var a = new A();

a.gen().next().value === result; //Should be true now it is : SyntaxErorr: super can only be used in a method of a derived class
Comment 2 GSkachkov 2016-03-02 23:59:01 PST
Created attachment 272737 [details]
Patch

Patch comming
Comment 3 Yusuke Suzuki 2016-03-03 04:54:37 PST
Comment on attachment 272737 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=272737&action=review

Nice catch. The approach looks nice. A few nits.

> Source/JavaScriptCore/parser/Parser.h:939
>      {

This function should be renamed to represent the returned scope is not generator's scope.
And please note that this function skips arrow function and generator, but it does not skip generator function.

> Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-superproperty.js:147
> +     }

Could you add tests like

method() {
    function *gen() {
         let arr = () => super.getValue();
         arr();
    }
}

This should be SyntaxError.
Comment 4 GSkachkov 2016-03-04 11:18:48 PST
Committed r197554: <http://trac.webkit.org/changeset/197554>
Comment 5 GSkachkov 2016-03-04 11:19:07 PST
All reviewed patches have been landed.  Closing bug.