Bug 272524 - Should throw syntax error for logical assignment that LHS is function call
Summary: Should throw syntax error for logical assignment that LHS is function call
Status: RESOLVED FIXED
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: 2024-04-11 06:26 PDT by Sosuke Suzuki
Modified: 2024-04-16 02:21 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sosuke Suzuki 2024-04-11 06:26:07 PDT
According to the spec[1], syntax error should be thrown for logical assignment expressions that LHS is a function call.

```js
function foo() {}
foo() &&= 3;
```

According to https://commits.webkit.org/223412@main, it was intentional that JSC not throw a syntax error for this.
However, four years have passed since then, and the related specifications have not been updated. Also V8 and SpiderMonkey throw his Syntax Error.

```
$ cat ./logical-assignment-syntax-error.js 
function foo() {}
foo() ??= 3;

$ eshost ./logical-assignment-syntax-error.js 
#### JavaScriptCore

ReferenceError: Left side of assignment is not a reference.

#### SpiderMonkey

SyntaxError: invalid assignment left-hand side:

#### V8

SyntaxError: Invalid left-hand side in assignment
```

So I think JSC should also follow the specifications.

[1]: https://tc39.es/ecma262/#sec-assignment-operators-static-semantics-early-errors
Comment 1 Sosuke Suzuki 2024-04-11 08:41:03 PDT
Pull request: https://github.com/WebKit/WebKit/pull/27145
Comment 2 EWS 2024-04-16 02:20:19 PDT
Committed 277536@main (b8cb1ca3b5f0): <https://commits.webkit.org/277536@main>

Reviewed commits have been landed. Closing PR #27145 and removing active labels.
Comment 3 Radar WebKit Bug Importer 2024-04-16 02:21:14 PDT
<rdar://problem/126540636>