Bug 152575

Summary: [ES6] Arrow function syntax. Lexical bind "super" inside of the arrow function in generator.
Product: WebKit Reporter: GSkachkov <gskachkov>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, keith_miller, mark.lam, msaboff, saam, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 145132    
Bug Blocks: 140855    
Attachments:
Description Flags
Patch ysuzuki: review+

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.