Closed Bug 1241966 Opened 8 years ago Closed 7 years ago

Better error when assigning to primitives in strict mode

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: evilpie, Assigned: evilpie)

References

(Blocks 2 open bugs)

Details

(Keywords: dev-doc-needed)

Attachments

(1 file, 1 obsolete file)

Jason:
> But what is up with that error message?
> 
>     typein:1:15 TypeError: can't assign to properties of (new
> Boolean(true)): not an object
> 
> WAT!

I looked into this before and the way we delay reporting the error message with ObjectOpResult probably requires some special casing for this.
Blocks: jserror
Flags: needinfo?(jorendorff)
Low priority but I'd like to do this...
Assignee: nobody → jorendorff
Flags: needinfo?(jorendorff)
Looking at nbp's counters for error messages (https://nbp.github.io/arewedocumentedyet/), this is actually relatively high.
We already know the the value originally was a primitive, so we might as well just unbox it. This is a bit of a hack, but at least we don't need to rejigger ObjectOpResult for this special case.
Assignee: jorendorff → evilpies
Status: NEW → ASSIGNED
Attachment #8912192 - Flags: review?(jorendorff)
Attachment #8912192 - Flags: review?(jorendorff) → review?(jdemooij)
Comment on attachment 8912192 [details] [diff] [review]
Unbox non-object receiver for error reporting

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

Nice. Add a test for a number of different primitives, to make sure we don't regress this? Checking the exact error message is fine probably.
Attachment #8912192 - Flags: review?(jdemooij) → review+
Sorry I should have written a test for this before. So I found out that we need to allow unboxing Symbol objects as well. This shouldn't change any behavior, because other callers check the object class before unboxing.
Attachment #8912192 - Attachment is obsolete: true
Attachment #8913993 - Flags: review?(jdemooij)
Comment on attachment 8913993 [details] [diff] [review]
v2 Unbox non-object receiver for error reporting

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

Good catch.
Attachment #8913993 - Flags: review?(jdemooij) → review+
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/417c277c6853
Unbox non-object receiver for better error reporting. r=jandem
Keywords: dev-doc-needed
https://hg.mozilla.org/mozilla-central/rev/417c277c6853
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Depends on: 1417962
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: