Closed Bug 1154532 Opened 9 years ago Closed 9 years ago

Add ThrowRangeError and ThrowTypeError self-hosting intrinsics

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

References

Details

Attachments

(1 file)

My %TypedArray%.prototype.set patch had a bug in it where I used ThrowError with an error message for an Error, when the spec required a RangeError be thrown.  This was totally non-obvious without going out of my way to consult js.msg.  Add self-hosting intrinsics like ThrowTypeError, with the exact same behavior as ThrowError now but asserting the error number's type is the expected one, to make clear at call sites what's happening, with assertions to verify it.
Attached patch PatchSplinter Review
I added the intrinsics, and I added a smattering of uses to demonstrate the intrinsics work.  But there's still a lot of work remaining to convert all ThrowError uses to a more-specific thing.

Interestingly, the spec appears to have *no* cases where Error is thrown.  And our self-hosted code appears not to have any places where ReferenceError, SyntaxError, or URIError are thrown.  So no adding corresponding intrinsics yet.
Attachment #8592549 - Flags: review?(till)
Comment on attachment 8592549 [details] [diff] [review]
Patch

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

Particularly nice.

::: js/src/vm/SelfHosting.cpp
@@ +154,5 @@
>                                JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS);
>  }
>  
> +static void
> +ThrowParticularError(JSContext* cx, JSExnType type, const CallArgs& args)

"ThrowErrorWithType", perhaps? "Particular" doesn't seem particularly descriptive in this particular use.
Attachment #8592549 - Flags: review?(till) → review+
Blocks: 1155081
https://hg.mozilla.org/mozilla-central/rev/76326ec30cd6
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: