-
-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(semantic)!: correct all
ReferenceFlags::Write
according to the …
…spec (#7388) close #7323 According to the specification re-design the JavaScript-part ReferenceFlags inferring approach. * https://tc39.es/ecma262/#sec-assignment-operators-runtime-semantics-evaluation * https://tc39.es/ecma262/#sec-postfix-increment-operator-runtime-semantics-evaluation * https://tc39.es/ecma262/#sec-runtime-semantics-restdestructuringassignmentevaluation * ... See references of https://tc39.es/ecma262/#sec-putvalue ### Changes 1. The left-hand of `AssignmentExpression` is always `ReferenceFlags::Write` ```js let a = 0; console.log(a = 0); ^ Write only ``` 2. The `argument` of `UpdateExpression` is always `ReferenceFlags::Read | Write` ```js let a = 0; a++; ^ Read and Write ``` This change might cause some trouble for `Minfier` to remove this code, because ‘a’ is not used elsewhere. I have taken a look at `esbuild` and `Terser`. Only the `Terser` can remove this code.
- Loading branch information
Showing
25 changed files
with
17,672 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let read = {}, write = {}; | ||
|
||
[write = read, [write = read]] = ref; |
54 changes: 54 additions & 0 deletions
54
crates/oxc_semantic/tests/fixtures/oxc/assignment/array.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
source: crates/oxc_semantic/tests/main.rs | ||
input_file: crates/oxc_semantic/tests/fixtures/oxc/assignment/array.js | ||
--- | ||
[ | ||
{ | ||
"children": [], | ||
"flags": "ScopeFlags(StrictMode | Top)", | ||
"id": 0, | ||
"node": "Program", | ||
"symbols": [ | ||
{ | ||
"flags": "SymbolFlags(BlockScopedVariable)", | ||
"id": 0, | ||
"name": "read", | ||
"node": "VariableDeclarator(read)", | ||
"references": [ | ||
{ | ||
"flags": "ReferenceFlags(Read)", | ||
"id": 1, | ||
"name": "read", | ||
"node_id": 17 | ||
}, | ||
{ | ||
"flags": "ReferenceFlags(Read)", | ||
"id": 3, | ||
"name": "read", | ||
"node_id": 25 | ||
} | ||
] | ||
}, | ||
{ | ||
"flags": "SymbolFlags(BlockScopedVariable)", | ||
"id": 1, | ||
"name": "write", | ||
"node": "VariableDeclarator(write)", | ||
"references": [ | ||
{ | ||
"flags": "ReferenceFlags(Write)", | ||
"id": 0, | ||
"name": "write", | ||
"node_id": 16 | ||
}, | ||
{ | ||
"flags": "ReferenceFlags(Write)", | ||
"id": 2, | ||
"name": "write", | ||
"node_id": 24 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.