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)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox52 --- wontfix
firefox57 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

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"
This issue needs to be re-evaluated after the changes from bug 1147371.
Mass wontfix for bugs affecting firefox 52.
Attached patch bug1315641.patch (obsolete) — Splinter Review
- 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)
Attachment #8898953 - Flags: review?(evilpies) → review+
Attached patch bug1315641.patchSplinter Review
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+
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
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: