Generator functions created through GeneratorFunction are incorrectly created as constructors

RESOLVED FIXED in Firefox 55

Status

()

Core
JavaScript Engine
RESOLVED FIXED
11 months ago
11 months ago

People

(Reporter: anba, Assigned: anba)

Tracking

(Blocks: 1 bug)

Trunk
mozilla55
Points:
---

Firefox Tracking Flags

(firefox55 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

11 months ago
Derived from https://github.com/tc39/test262/blob/master/test/built-ins/GeneratorFunction/instance-construct-throws.js:
---
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
var instance = GeneratorFunction();
new instance();
---

Expected: Throws TypeError
Actual: No TypeError
(Assignee)

Comment 1

11 months ago
Created attachment 8855779 [details] [diff] [review]
bug1354529.patch

I don't think it matters whether async functions and async generators use INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC or INTERPRETED_LAMBDA due to the wrapping. Is that correct?
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8855779 - Flags: review?(arai.unmht)

Comment 2

11 months ago
Comment on attachment 8855779 [details] [diff] [review]
bug1354529.patch

Review of attachment 8855779 [details] [diff] [review]:
-----------------------------------------------------------------

thanks!

(In reply to André Bargull from comment #1)
> I don't think it matters whether async functions and async generators use
> INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC or INTERPRETED_LAMBDA due to the
> wrapping. Is that correct?

correct.

just to be sure, this is tested by the test262 (maybe added in the next update?), right?
Attachment #8855779 - Flags: review?(arai.unmht) → review+
(Assignee)

Comment 3

11 months ago
(In reply to Tooru Fujisawa [:arai] from comment #2)
> (In reply to André Bargull from comment #1)
> > I don't think it matters whether async functions and async generators use
> > INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC or INTERPRETED_LAMBDA due to the
> > wrapping. Is that correct?
> 
> correct.

Great!

> 
> just to be sure, this is tested by the test262 (maybe added in the next
> update?), right?

Yes, this is tested by https://github.com/tc39/test262/blob/master/test/built-ins/GeneratorFunction/instance-construct-throws.js (which is not yet in our local test262 copy). I've verified this test fails without the patch, and passes when the patch is applied.

Comment 5

11 months ago
Pushed by ihsiao@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/448b205d97fd
Don't set constructor-flag for generator functions created through GeneratorFunction intrinsic. r=arai
Keywords: checkin-needed

Comment 6

11 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/448b205d97fd
Status: ASSIGNED → RESOLVED
Last Resolved: 11 months ago
status-firefox55: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.