-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make expr_simplifier
handle expressions when indexing strings, arrays and objects
#8750
Open
levi-nz
wants to merge
74
commits into
swc-project:main
Choose a base branch
from
levi-nz:issue-8747
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 42 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
84ec94e
Initial commit: string literals
levi-nz 7f02ace
WIP: array literals
levi-nz 2b94d3d
Correctly handle array indexing
levi-nz efec60b
Update unit test
levi-nz 72537ac
Fix broken index logic
levi-nz 454378d
Fix indexing `ObjectLit`s
levi-nz 9b26630
Remove fraction check from `LiteralVisitor`
levi-nz 677a437
cargo fmt
levi-nz 3aa713e
Update test files
levi-nz 8450f8b
Handle `x['0']`
levi-nz 2b8709f
Don't return `KnownOp::Len` if `obj` is an ObjectLiteral
levi-nz dd4336b
Handle `x['length']`
levi-nz 2fe5f09
Correctly handle builtin properties
levi-nz c902739
Don't replace ArrayLiteral if doing so may have side effects
levi-nz b4455c9
Update unit test
levi-nz ae673de
Update minifier test files
levi-nz 4143a27
cargo fmt
levi-nz 4b151fc
Minifier shouldn't handle potential `pristine_globals` cases
levi-nz c154047
cargo fmt
levi-nz 647cfd3
Update test files
levi-nz 9c9d141
Don't add a dummy value if no side effects exist
levi-nz 4424755
Update test files
levi-nz 96a1c0b
Oops
levi-nz 5104b9a
Update unit test
levi-nz bfd376b
Add test case for side effects
levi-nz 9296237
Add compression for `MemberExpr`
levi-nz 2b26790
cargo fmt
levi-nz 4f2c69f
String does not appear to inherit Function
levi-nz 43fe050
Array also does not inherit Function
levi-nz 70f6f64
Remove comment
levi-nz d19e907
`FUNCTION_SYMBOLS` is no longer required
levi-nz 10c4681
Add unit test files
levi-nz 240713a
Update test files
levi-nz ec03388
Update test config
levi-nz bfcb5cf
Better test dir names
levi-nz 17439b9
Remove evil clone
levi-nz 67474ef
I don't know why this changed, but it did.
levi-nz c92508f
Add array side effect unit test
levi-nz 9407838
Don't optimize if inside left-hand side of AssignExpr
levi-nz 942a343
Remove redundant import
levi-nz 5424fed
Move call to end
levi-nz c6029c4
Cleanup iterator call
levi-nz ea89ec2
Handle side effects and `__proto__` in object compression
levi-nz 976ddb7
Remove redundant return statement
levi-nz a819d98
cargo fmt
levi-nz b41617c
Remove redundant `Box::new` call
levi-nz a5df0a5
Use `preserve_effects`
levi-nz e47bff3
cargo fmt
levi-nz 52dfab4
Exclude `watch` and `unwatch`
levi-nz 4a1b6db
UPDATE=1 cargo test --test projects --test tsc
levi-nz d4696ed
UPDATE=1 cargo test -p swc_ecma_minifier --features concurrent
levi-nz 7dba5ac
git merge upstream/main issue-8747
levi-nz 00cb04f
Remove redundant import
levi-nz 6477fbf
Fix `test_fold_array_lit_spread_get_elem`
levi-nz 9b5239d
Fix `test_fold_get_elem1`
levi-nz f3cfa71
Add `self.changed = true;`
levi-nz b8cd66b
Use `ctx`
levi-nz b2a2cc6
Fix doc
levi-nz 5458077
Handle SeqExpr in `optimize_member_expr`
levi-nz 5e1819f
Remove dup `self.changed = true;`
levi-nz 4a2d3a9
git merge upstream/main issue-8747
levi-nz 45d23d3
Apply clippy suggestions
levi-nz 52869c4
Cleanup `optimize_member_expr`
levi-nz aa42961
Fix optimization tests
levi-nz 2b7ab8e
Fix optimization with `OptCall`
levi-nz 03c7dd5
Move code into its own `eval` function
levi-nz 60bcf71
Fix error
levi-nz d613a05
Remove redundant imports
levi-nz 2b5da79
Optimize imports
levi-nz 66c51a4
Update parserForStatement9.2.minified.js
levi-nz cc2dcab
Cleanup simplify
levi-nz dca62ff
Handle `__proto__` object when indexing known object keys
levi-nz c913a15
cargo fmt
levi-nz 4e73a33
Remove `is_opt_call`
levi-nz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment2.2.minified.js
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
4 changes: 1 addition & 3 deletions
4
crates/swc/tests/tsc-references/destructuringControlFlow.2.minified.js
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
//// [destructuringControlFlow.ts] | ||
import "@swc/helpers/_/_sliced_to_array"; | ||
[ | ||
"foo" | ||
][1].toUpperCase(); | ||
(void 0).toUpperCase(); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/parserForStatement9.2.minified.js
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
//// [parserForStatement9.ts] | ||
for(var tmp = [][0], x = void 0 === tmp ? ("a" in {}) : tmp; !x; x = !x)console.log(x); | ||
for(var tmp = void 0, x = void 0 === tmp ? ("a" in {}) : tmp; !x; x = !x)console.log(x); | ||
for(var _ref_x = {}.x, x1 = void 0 === _ref_x ? ("a" in {}) : _ref_x; !x1; x1 = !x1)console.log(x1); |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/templateStringInIndexExpressionES6.2.minified.js
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
//// [templateStringInIndexExpressionES6.ts] | ||
"abc0abc"["0"]; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you apply https://github.com/mainmatter/cargo-autoinherit ?