Closed Bug 1197094 Opened 4 years ago Closed 4 years ago

ForOfIterator calls ToObject on iterable

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox43 --- affected
firefox45 --- fixed

People

(Reporter: anba, Assigned: mrrrgn)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Test case:
---
Object.defineProperty(Number.prototype, Symbol.iterator, {
  value() {
    "use strict";
    print("typeof", typeof this);
    return { next() { return {done: true}; } };
  }
});
new Map(0);
---


Expected: Prints "typeof number"
Actual: Prints "typeof object"
Blocks: es6
Assignee: nobody → winter2718
A nice gimme to end the week with.
Attached patch forofobj.diffSplinter Review
Attachment #8696100 - Flags: review?(evilpies)
Comment on attachment 8696100 [details] [diff] [review]
forofobj.diff

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

::: js/src/vm/ForOfIterator.cpp
@@ +57,4 @@
>  
>      RootedValue callee(cx);
>      RootedId iteratorId(cx, SYMBOL_TO_JSID(cx->wellKnownSymbols().iterator));
>      if (!GetProperty(cx, iterableObj, iterableObj, iteratorId, &callee))

I wonder if we need to change this to iterable as well in the future.
Attachment #8696100 - Flags: review?(evilpies) → review+
https://hg.mozilla.org/mozilla-central/rev/ec1df10696ab
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.