Better error when assigning to primitives in strict mode

RESOLVED FIXED in Firefox 58

Status

()

Core
JavaScript Engine
RESOLVED FIXED
2 years ago
18 days ago

People

(Reporter: evilpie, Assigned: evilpie)

Tracking

(Blocks: 2 bugs, {dev-doc-needed})

unspecified
mozilla58
dev-doc-needed
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox58 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

2 years ago
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.
(Assignee)

Updated

2 years ago
Blocks: 622261
(Assignee)

Updated

2 years ago
Duplicate of this bug: 1260131
Flags: needinfo?(jorendorff)
Low priority but I'd like to do this...
Assignee: nobody → jorendorff
Flags: needinfo?(jorendorff)
(Assignee)

Comment 3

4 months ago
Looking at nbp's counters for error messages (https://nbp.github.io/arewedocumentedyet/), this is actually relatively high.
(Assignee)

Comment 4

25 days ago
Created attachment 8912192 [details] [diff] [review]
Unbox non-object receiver for error reporting

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)
(Assignee)

Updated

22 days ago
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+
(Assignee)

Comment 6

20 days ago
Created attachment 8913993 [details] [diff] [review]
v2 Unbox non-object receiver for error reporting

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+

Comment 8

19 days ago
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/417c277c6853
Unbox non-object receiver for better error reporting. r=jandem
(Assignee)

Updated

19 days ago
Keywords: dev-doc-needed

Comment 9

18 days ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/417c277c6853
Status: ASSIGNED → RESOLVED
Last Resolved: 18 days ago
status-firefox58: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.