Make assignment to const throw runtime TypeError regardless of strictness

RESOLVED FIXED in Firefox 44

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: shu, Assigned: shu)

Tracking

(Blocks: 1 bug)

unspecified
mozilla44
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox44 fixed)

Details

Attachments

(3 attachments)

(Assignee)

Description

3 years ago
Per ES6.
(Assignee)

Comment 1

3 years ago
Created attachment 8674622 [details] [diff] [review]
Make assignment to const errors runtime TypeErrors in the frontend and interpreter.
Attachment #8674622 - Flags: review?(jdemooij)
(Assignee)

Comment 2

3 years ago
Created attachment 8674623 [details] [diff] [review]
Make assignment to const errors runtime TypeErrors in the JITs.
Attachment #8674623 - Flags: review?(jdemooij)
(Assignee)

Comment 3

3 years ago
Created attachment 8674624 [details] [diff] [review]
Update tests.
Attachment #8674624 - Flags: review?(jdemooij)
(Assignee)

Updated

3 years ago
Assignee: nobody → shu
Status: NEW → ASSIGNED
Attachment #8674622 - Flags: review?(jdemooij) → review+
Comment on attachment 8674623 [details] [diff] [review]
Make assignment to const errors runtime TypeErrors in the JITs.

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

::: js/src/jit/MIR.h
@@ +7277,4 @@
>  {
> +    unsigned errorNumber_;
> +
> +    MThrowRuntimeLexicalError(unsigned errorNumber)

Nit: `explicit`
Attachment #8674623 - Flags: review?(jdemooij) → review+
Comment on attachment 8674624 [details] [diff] [review]
Update tests.

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

::: js/src/jit-test/tests/basic/constAssignError.js
@@ +8,5 @@
>  
> +assertTypeError("(function() { const x = 3; (function() x++)(); return x })()");
> +assertTypeError("(function() { const x = 3; (function() x++)(); return x++ })()");
> +assertTypeError("(function() { const x = 2; (function() x++)(); return ++x })()");
> +assertTypeError("(function() { const x = 2; (function() x++)(); return x += 1 })()");

While you're fixing this test, would you mind changing (4 times)
  (function() x++)
to
  (() => x++)

No deprecated syntax and nice to have a test for assigning to consts in arrows.
Attachment #8674624 - Flags: review?(jdemooij) → review+
https://hg.mozilla.org/mozilla-central/rev/99fb98710182
https://hg.mozilla.org/mozilla-central/rev/731543183177
https://hg.mozilla.org/mozilla-central/rev/3664bbd6853b
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox44: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Depends on: 1215992
Depends on: 1216156
Duplicate of this bug: 1138736
Blocks: 694100
You need to log in before you can comment on or make changes to this bug.