Closed Bug 1338796 Opened 9 years ago Closed 9 years ago

IteratorClose shouldn't be called in yield* when resuming generator with Throw completion and throw method is present

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox53 --- fixed
firefox54 --- fixed

People

(Reporter: anba, Assigned: shu)

References

Details

Attachments

(1 file)

Test case: --- var iterable = { [Symbol.iterator]() { return { next(x) { print("NEXT called"); return { done: false }; }, return(x) { print("RETURN called"); return { done: true }; }, throw(e) { print("THROW called"); throw e; }, }; } }; function* y() { yield* iterable; } var g1 = y(); g1.next(); try { g1.throw(); } catch (e) { } --- Expected: Prints "NEXT called" and then "THROW called", but doesn't print "RETURN called" Actual: Also prints "RETURN called" Test case is derived from ecma_6/Generators/yield-star-iterator-close.js
I refactored the iterator.return() code due to yield* out of emitIteratorClose, because the semantics are fairly different. This lets emitIteratorClose to be easier to read and be 1:1 with the spec text.
Attachment #8836975 - Flags: review?(arai.unmht)
Comment on attachment 8836975 [details] [diff] [review] Do not call iterator.return if iterator.throw is present in yield*. Review of attachment 8836975 [details] [diff] [review]: ----------------------------------------------------------------- yeah, now it's easy to follow the execution, nice :) ::: js/src/frontend/BytecodeEmitter.cpp @@ +8306,5 @@ > + // Step v. > + if (!emitCheckIsObj(CheckIsObjectKind::IteratorReturn)) // ITER OLDRESULT FTYPE FVALUE RESULT > + return false; > + > + // Step vi-viii. Steps
Attachment #8836975 - Flags: review?(arai.unmht) → review+
Pushed by shu@rfrn.org: https://hg.mozilla.org/integration/mozilla-inbound/rev/697c73202fb6 Do not call iterator.return if iterator.throw is present in yield*. (r=arai)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
Assignee: nobody → shu
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: