Bug 247788 - Invalid postfix operator and nullish coaleascing inside a block in strict mode
Summary: Invalid postfix operator and nullish coaleascing inside a block in strict mode
Status: RESOLVED CONFIGURATION CHANGED
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:16 PST by Kanguk Lee
Modified: 2023-03-14 16:13 PDT (History)
5 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: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!