Bug 247431

Summary: Ignored TypeError upon optional function call chain
Product: WebKit Reporter: Kanguk Lee <p51lee>
Component: JavaScriptCoreAssignee: Ross Kirsling <ross.kirsling>
Status: RESOLVED FIXED    
Severity: Normal CC: mark.lam, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   

Description Kanguk Lee 2022-11-03 09:03:35 PDT
// input.js
var x = function ( ) { } ?. ( ) . x ;
__________________________________________

Hello,

Executing the input.js using JSC, it is terminated normally.
However, it is expected to throw TypeError since `function ( ) { } ?. ( )` is `undefined`.

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: Cannot read properties of undefined (reading 'x')
var x = function ( ) { } ?. ( ) . x ;
                                ^
TypeError: Cannot read properties of undefined (reading 'x')
    at input.js:1:33

# GraalJS
$ js input.js
TypeError: Cannot read property 'x' of undefined
	at <js> :program(input.js:1:8-34)
---


WebKit version: 615.1.10
Comment 1 Radar WebKit Bug Importer 2022-11-03 18:13:16 PDT
<rdar://problem/101940388>
Comment 2 Ross Kirsling 2022-11-24 17:26:24 PST
*** Bug 247434 has been marked as a duplicate of this bug. ***
Comment 3 Ross Kirsling 2022-11-24 17:58:17 PST
Pull request: https://github.com/WebKit/WebKit/pull/6799
Comment 4 EWS 2022-11-24 21:45:03 PST
Committed 257004@main (23879e6bd1a0): <https://commits.webkit.org/257004@main>

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