Bug 247428 - Reassigning to class name during static field initialization
Summary: Reassigning to class name during static field initialization
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
Depends on:
Blocks:
 
Reported: 2022-11-03 08:52 PDT by Kanguk Lee
Modified: 2022-11-14 11:56 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 08:52:52 PDT
// input.js
class x { static #y = { x = 0 } = 0 ; }
__________________________________________

Hello,

Executing the input.js using JSC throws ReferenceError.
However, it is expected to throw TypeError.

Running the input.js with JSC results in:

---
$ jsc input.js
Exception: ReferenceError: Cannot access uninitialized variable.
global code@input.js:1:1
---

while other engines behave like:

---
# V8
$ node input.js
input.js:1: TypeError: Assignment to constant variable.
class x { static #y = { x = 0 } = 0 ; }
                        ^
TypeError: Assignment to constant variable.
    at <static_initializer> (input.js:1:25)
    at input.js:1:1

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


WebKit version: 615.1.10
Comment 1 Radar WebKit Bug Importer 2022-11-10 07:53:17 PST
<rdar://problem/102193862>
Comment 2 Yijia Huang 2022-11-10 18:01:27 PST
Pull request: https://github.com/WebKit/WebKit/pull/6381
Comment 3 EWS 2022-11-14 11:56:34 PST
Committed 256663@main (68f502ba813d): <https://commits.webkit.org/256663@main>

Reviewed commits have been landed. Closing PR #6381 and removing active labels.