Closed
Bug 1315641
Opened 9 years ago
Closed 8 years ago
Change error messages in self-hosted GetIterator function
Categories
(Core :: JavaScript: Standard Library, enhancement)
Core
JavaScript: Standard Library
Tracking
()
RESOLVED
FIXED
mozilla57
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
|
7.24 KB,
patch
|
anba
:
review+
|
Details | Diff | Splinter Review |
The self-hosted GetIterator function should use the same error messages for invalid iterators as used by other parts of the engine:
---
js> new Map({[Symbol.iterator]: 1})
typein:1:1 TypeError: ({[Symbol.iterator]:1}) is not iterable
Stack:
@typein:1:1
js> ([] = {[Symbol.iterator]: 1})
typein:2:8 TypeError: ({[Symbol.iterator]:1}) is not iterable
Stack:
@typein:2:8
js> Int8Array.from({[Symbol.iterator]: 1})
typein:3:1 TypeError: number is not a function
Stack:
@typein:3:1
---
Expected: Int8Array.from() reports "... is not iterable".
Actual: Int8Array.from() reports "... is not a function"
And:
---
js> new Map({[Symbol.iterator]: () => 1})
typein:1:1 TypeError: number is not a non-null object
Stack:
@typein:1:1
js> Int8Array.from({[Symbol.iterator]: () => 1})
typein:2:1 TypeError: 1 is not iterable
Stack:
@typein:2:1
---
Expected: Int8Array.from() reports "... is not a non-null object".
Actual: Int8Array.from() reports "... is not iterable"
| Assignee | ||
Comment 1•9 years ago
|
||
This issue needs to be re-evaluated after the changes from bug 1147371.
Comment 2•9 years ago
|
||
Mass wontfix for bugs affecting firefox 52.
| Assignee | ||
Comment 3•8 years ago
|
||
- Inlines GetMethod in ArrayFrom and TypedArrayStaticFrom, so we can throw a custom error message (JSMSG_NOT_ITERABLE) instead of the default JSMSG_NOT_FUNCTION.
- Changes the error message in GetIterator to JSMSG_GET_ITER_RETURNED_PRIMITIVE and removes the now unused JSMSG_NOT_ITERATOR.
- And since ArrayFrom uses for-of iteration, we don't actually need the extra GetIterator call, which improves the following µ-benchmark from 165ms to 145ms for me:
var items = [];
var t = dateNow();
for (var i = 0; i < 1000000; ++i) {
Array.from(items);
}
print(dateNow() - t);
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8898953 -
Flags: review?(evilpies)
Updated•8 years ago
|
Attachment #8898953 -
Flags: review?(evilpies) → review+
| Assignee | ||
Comment 4•8 years ago
|
||
I forgot to update this assertion (http://searchfox.org/mozilla-central/rev/5696c3e525fc8222674eed6a562f5fcbe804c4c7/js/src/builtin/Array.js#846) in ArrayFrom to handle |null|. But in the end I decided to simply replace the assertion with a comment similar to the one in TypedArrayFrom (http://searchfox.org/mozilla-central/rev/5696c3e525fc8222674eed6a562f5fcbe804c4c7/js/src/builtin/TypedArray.js#1487-1488).
Attachment #8898953 -
Attachment is obsolete: true
Attachment #8901133 -
Flags: review+
| Assignee | ||
Comment 5•8 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=9bdad241dea901c0008faec4df1065f2f85edde9
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/711cba275460
Align error messages for (Typed)Array.from with standard iteration error messages. r=evilpie
Keywords: checkin-needed
Comment 7•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox57:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in
before you can comment on or make changes to this bug.
Description
•