Bug 247788

Summary: Invalid postfix operator and nullish coaleascing inside a block in strict mode
Product: WebKit Reporter: Kanguk Lee <p51lee>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: justin_michaud, mark.lam, ross.kirsling, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   

Description Kanguk Lee 2022-11-11 01:16:24 PST
// input.js
"use strict";
function f() {
  x = (``.p++) ?? 0;
  let x;
}

f();
_____________________

Hello,

Executing the input.js using JSC, it throws ReferenceError but TypeError is expected.

Running the input.js with JSC results in:

---
$ jsc input.js
Exception: ReferenceError: Cannot access uninitialized variable.
f@input.js:3:10
global code@input.js:7:2
---

while other engines behave like:

---
# V8 (used console.log)
$ node input.js
input.js:3
  x = (``.p++) ?? 0;
           ^

TypeError: Cannot create property 'p' on string ''
...

Node.js v18.11.0

# GraalJS
$ js input.js
TypeError: Cannot assign to read only property 'p' of
	at <js> f(input.js:3:35-42)
	at <js> :program(input.js:7:62-64)
---


WebKit version: 615.1.10
Comment 1 Radar WebKit Bug Importer 2022-11-14 09:34:19 PST
<rdar://problem/102324685>
Comment 2 Ross Kirsling 2022-11-21 17:24:41 PST
This is already a TypeError in current JSC; seems like something must have changed since the last Safari TP release.
Comment 3 Justin Michaud 2023-03-14 16:13:05 PDT
Yes, this seems to be fixed. Thanks for reporting!