Summary: | [ES6][ES7] Drop Constructability of generator function | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Yusuke Suzuki <ysuzuki> | ||||||
Component: | JavaScriptCore | Assignee: | Yusuke Suzuki <ysuzuki> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | benjamin, commit-queue, fpizlo, ggaren, keith_miller, mark.lam, msaboff, saam | ||||||
Priority: | P2 | ||||||||
Version: | WebKit Nightly Build | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Attachments: |
|
Description
Yusuke Suzuki
2015-12-17 02:44:11 PST
Working on this. Created attachment 267926 [details]
Patch
Is there a strong chance this could change before ES7 is finalized? (In reply to comment #3) > Is there a strong chance this could change before ES7 is finalized? If something happens or better semantics is invested, it could be changed in the future. But I don't think this behavior will be reverted. Because of inconsistency of the current behavior, even if the currently proposed one won't be landed as is, the ES2015 behavior will be changed anyway. (So, anyway, I think we will be required to change the current form in the future) Because, 1. The current form is not consistent to the class constructor behavior. We cannot define (class A { *constructor() { } }), but the generator is constructible. 2. As described in the https://github.com/tc39/tc39-notes/blob/master/es7/2015-07/july-28.md#67-new--generatorfunction, `new` on the generator does not provide any useful things. |this| becomes TDZ, so we cannot touch the constructed object. And since its body is not the part of the constructor, It will be called when calling next(). So there's no chance to initialize |this| with the constructor (like, setting some properties etc.) even if |this| in `new generatorFunction()` represents the constructed object. Comment on attachment 267926 [details]
Patch
Ok. SGTM
Comment on attachment 267926 [details] Patch Clearing flags on attachment: 267926 Committed r194435: <http://trac.webkit.org/changeset/194435> All reviewed patches have been landed. Closing bug. Reopening to attach new patch. Created attachment 267984 [details]
Patch
Committed r194436: <http://trac.webkit.org/changeset/194436> |