Bug 247786 - Re-assignment to constant variable in for-in head
Summary: Re-assignment to constant variable in for-in head
Status: RESOLVED DUPLICATE of bug 247432
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-11-11 01:00 PST by Kanguk Lee
Modified: 2022-11-14 10:23 PST (History)
4 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-11 01:00:17 PST
// input.js
const x = 0 ; for ( { x } in [ 1 ] ) ; 
_____________________

Hello,

Executing the input.js using JSC, it terminates normally, but TypeError is expected since there is an assignment to const.

Running the input.js with JSC results in:

---
$ jsc input.js
async
---

while other engines behave like:

---
# V8 (used console.log)
$ node input.js
input.js:1
const x = 0 ; for ( { x } in [ 1 ] ) ;
                      ^

TypeError: Assignment to constant variable.
    at Object.<anonymous> (input.js:1:23)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.11.0

# 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-14 09:42:07 PST
<rdar://problem/102325113>
Comment 2 Yijia Huang 2022-11-14 10:23:08 PST
This should be a duplicate of https://bugs.webkit.org/show_bug.cgi?id=247432 and should be fixed in PR https://commits.webkit.org/256580@main.

Just tested on ToT https://commits.webkit.org/256659@main. It is fixed.

*** This bug has been marked as a duplicate of bug 247432 ***