Closed
Bug 725168
Opened 13 years ago
Closed 13 years ago
Element iterators should use [[Get]] and not peculiarly ignore the prototype chain
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla13
People
(Reporter: jorendorff, Assigned: jorendorff)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
4.42 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
This only matters in dumb corner cases, but basically:
Array.prototype[2] = "potato";
for (let x of [0, 1, , 3])
print(x);
should print 0, 1, "potato", 3
rather than 0, 1, undefined, 3.
Assignee | ||
Comment 1•13 years ago
|
||
I don't know what I was thinking. Just randomly hating on holes.
The fast path for dense arrays could be thrown away too. It really depends on how we want to implement this.
Attachment #595257 -
Flags: review?(jwalden+bmo)
Updated•13 years ago
|
Attachment #595257 -
Attachment is patch: true
Comment 2•13 years ago
|
||
Comment on attachment 595257 [details] [diff] [review]
v1
Review of attachment 595257 [details] [diff] [review]:
-----------------------------------------------------------------
Agreed about throwing out the dense array fast path, I think. We can pick up fast paths when they're demonstrably necessary; in the meantime, clarity and concision are more important.
::: js/src/jsiter.cpp
@@ -1153,5 @@
> - } else {
> - Value v = DoubleValue(i);
> - if (!js_ValueToStringId(cx, v, &id))
> - goto error;
> - }
Did I review this code and not require IndexToString? :-(
Attachment #595257 -
Flags: review?(jwalden+bmo) → review+
Comment 3•13 years ago
|
||
Oh, I express no position on whether it is better to have for-of look up the prototype chain (as happens with this patch) or look only at own properties (as happens currently). Definitely whatever the rationale is should be recorded in this bug, tho.
Assignee | ||
Comment 4•13 years ago
|
||
The rationale, in broad strokes:
- it is more like the canonical for loop that way
- nothing in the language currently does this kind of "get if own property";
for better or worse, everything uses [[Get]]
- just how unusual this is shows up as code complexity
- everybody says ignoring the prototype chain won't make for-of any faster
In any case TC39 will kick this back and forth and eventually come to some decision, and we'll implement that.
Assignee | ||
Comment 5•13 years ago
|
||
Incidentally, removing the "simple" fast path fixes bug 726212, so the patch I check in for that bug will just be a few tests.
Assignee | ||
Comment 6•13 years ago
|
||
Comment 7•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
Comment 8•13 years ago
|
||
Nice diffstat!
You need to log in
before you can comment on or make changes to this bug.
Description
•