Bug 247493

Summary: Order between initializing x and this.x in strict mode
Product: WebKit Reporter: Kanguk Lee <p51lee>
Component: JavaScriptCoreAssignee: Yijia Huang <yijia_huang>
Status: RESOLVED WONTFIX    
Severity: Normal CC: mark.lam, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Mac (Apple Silicon)   
OS: macOS 12   
Attachments:
Description Flags
I captured ECMAScript 2022 section 13.15.2. none

Description Kanguk Lee 2022-11-04 09:59:29 PDT
Created attachment 463411 [details]
I captured ECMAScript 2022 section 13.15.2.

// input.js
"use strict";
x = this.x = 0;
________________________________

Hello,

Executing the input.js using JSC terminates normally, but it is expected to throw ReferenceError.

According to ECMAScript 2022 section 13.15.2: Evaluation of `*AssignmentExpression* : *LeftHandSideExpression* = *AssignmentExpression*`,

(link: https://tc39.es/ecma262/2022/multipage/ecmascript-language-expressions.html#sec-assignment-operators-runtime-semantics-evaluation)

in line 1-a, *LeftHandSideExpression*, i.e. `x` should be evaluated first and the evaluation result is an unresolvable reference.

Therefore PutValue() in line 1-e throws ReferenceError because strict mode is turned on.


WebKit version: 615.1.10
Comment 1 Radar WebKit Bug Importer 2022-11-07 16:24:45 PST
<rdar://problem/102064848>
Comment 2 Yijia Huang 2022-11-13 00:15:36 PST
Pull request: https://github.com/WebKit/WebKit/pull/6438
Comment 3 Yusuke Suzuki 2022-11-14 11:03:47 PST
Ross pointed out that this is spec issue actually.
https://github.com/WebKit/WebKit/pull/6438#issuecomment-1312694884
https://github.com/WebKit/WebKit/pull/6438#issuecomment-1312922522
We close this since the spec will be upgraded.