Closed Bug 1543650 Opened 7 years ago Closed 6 years ago

Replace JSMSG_NOT_BIGINT with more descriptive error messages

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: anba, Assigned: evilpies)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

https://searchfox.org/mozilla-central/rev/69ace9da347adcc4a33c6fa3d8e074759b91068c/js/src/vm/BigIntType.cpp#2687 should include the type and/or value of v. So instead of throwing TypeError: not a BigInt, it should throw TypeError: can't convert xxx to BigInt.

Example:

js> new BigInt64Array([2])
typein:1:1 TypeError: not a BigInt
Stack:
  @typein:1:1

https://searchfox.org/mozilla-central/rev/69ace9da347adcc4a33c6fa3d8e074759b91068c/js/src/vm/TypedArrayObject.cpp#1355 and https://searchfox.org/mozilla-central/rev/69ace9da347adcc4a33c6fa3d8e074759b91068c/js/src/vm/TypedArrayObject.cpp#1768 should include the source and target typed array types or describe somehow that the typed array element types are incompatible.

Example:

js> new BigInt64Array(new Int32Array)
typein:2:1 TypeError: not a BigInt
Stack:
  @typein:2:1
Type: task → enhancement
Priority: -- → P3
Assignee: nobody → evilpies
Status: NEW → ASSIGNED
Keywords: leave-open

I am open to wording improvements for the error message. Right now we get:

js> new BigInt64Array(new Float32Array(4))
TypeError: Float32Array array elements are incompatible with BigInt64Array

and

js> x = new Float32Array(4); x.set(new BigInt64Array(2))
TypeError: BigInt64Array array elements are incompatible with Float32Array

Depends on D57199

Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/9980078d96a3 Throw better error message in ToBigInt. r=arai https://hg.mozilla.org/integration/autoland/rev/3b3c8d649109 Improve error message when using incompatible typed (BigInt) arrays. r=arai
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Keywords: leave-open
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: