RESOLVED FIXED 152383
[ES6][ES7] Drop Constructability of generator function
https://bugs.webkit.org/show_bug.cgi?id=152383
Summary [ES6][ES7] Drop Constructability of generator function
Yusuke Suzuki
Reported 2015-12-17 02:44:11 PST
In ES7, the generator function becomes non-constructible. This is good for the current JSC implementation. We no longer need to consider about newTarget when creating a generator. And this is already introduced in ECMA262 2016 draft. https://github.com/tc39/ecma262/releases/tag/es2016-draft-20151201 https://github.com/tc39/tc39-notes/blob/master/es7/2015-07/july-28.md#67-new--generatorfunction https://github.com/tc39/tc39-notes/blob/master/es7/2015-07/july-29.md#revisit-67-new--generatorfunction
Attachments
Patch (37.20 KB, patch)
2015-12-26 08:07 PST, Yusuke Suzuki
no flags
Patch (1.58 KB, patch)
2015-12-29 05:57 PST, Yusuke Suzuki
no flags
Yusuke Suzuki
Comment 1 2015-12-26 07:47:53 PST
Working on this.
Yusuke Suzuki
Comment 2 2015-12-26 08:07:40 PST
Saam Barati
Comment 3 2015-12-27 22:42:23 PST
Is there a strong chance this could change before ES7 is finalized?
Yusuke Suzuki
Comment 4 2015-12-28 06:24:17 PST
(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.
Saam Barati
Comment 5 2015-12-28 13:01:24 PST
Comment on attachment 267926 [details] Patch Ok. SGTM
WebKit Commit Bot
Comment 6 2015-12-29 03:49:58 PST
Comment on attachment 267926 [details] Patch Clearing flags on attachment: 267926 Committed r194435: <http://trac.webkit.org/changeset/194435>
WebKit Commit Bot
Comment 7 2015-12-29 03:50:02 PST
All reviewed patches have been landed. Closing bug.
Yusuke Suzuki
Comment 8 2015-12-29 05:57:06 PST
Reopening to attach new patch.
Yusuke Suzuki
Comment 9 2015-12-29 05:57:10 PST
Yusuke Suzuki
Comment 10 2015-12-29 05:57:45 PST
Note You need to log in before you can comment on or make changes to this bug.