Bug 247432 - TypeError is expected when reassigning to `const` during destructuring in for statement
Summary: TypeError is expected when reassigning to `const` during destructuring in for...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yijia Huang
URL:
Keywords: InRadar
: 247786 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-11-03 09:06 PDT by Kanguk Lee
Modified: 2022-11-14 10:23 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kanguk Lee 2022-11-03 09:06:03 PDT
// input.js
const x = 0 ; for ( { x } in { x } ) ;
__________________________________________

Hello,

Executing the input.js using JSC, it is terminated normally.
However, it is expected to throw TypeError since there is an assignment to constant variable.

Running the input.js with JSC results in:

---
$ jsc input.js
// no error
---

while other engines behave like:

---
# V8
$ node input.js
input.js:1: TypeError: Assignment to constant variable.
const x = 0 ; for ( { x } in { x } ) ;
                      ^
TypeError: Assignment to constant variable.
    at input.js:1:23

# GraalJS
$ js input.js
TypeError: Assignment to constant "x"
	at <js> :program(input.js:1:22)
---


WebKit version: 615.1.10
Comment 1 Radar WebKit Bug Importer 2022-11-07 16:18:34 PST
<rdar://problem/102064568>
Comment 2 Yijia Huang 2022-11-10 23:54:56 PST
Pull request: https://github.com/WebKit/WebKit/pull/6390
Comment 3 EWS 2022-11-11 11:11:55 PST
Committed 256580@main (c228e7cdd637): <https://commits.webkit.org/256580@main>

Reviewed commits have been landed. Closing PR #6390 and removing active labels.
Comment 4 Yijia Huang 2022-11-14 10:23:08 PST
*** Bug 247786 has been marked as a duplicate of this bug. ***