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
fix(es/minifier): Fix ordering issue of analyzer #6150
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ee4e409
`Default`
kdy1 00fb0f5
Trivial
kdy1 ca468ff
Move more code
kdy1 dd5679b
Fix ordering issue
kdy1 9b54c65
Update test refs
kdy1 a3400ab
Fix ordering issue completely
kdy1 bb7fc88
Merge branch 'main' into flat
swc-bot 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
5 changes: 2 additions & 3 deletions
5
crates/swc/tests/tsc-references/classDeclarationLoop.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,9 +1,8 @@ | ||
//// [classDeclarationLoop.ts] | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
for(var _loop = function(i) { | ||
var C = function C() { | ||
arr.push(function C() { | ||
"use strict"; | ||
_class_call_check(this, C), this.prop = i; | ||
}; | ||
arr.push(C); | ||
}); | ||
}, arr = [], i = 0; i < 10; ++i)_loop(i); |
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 |
---|---|---|
|
@@ -153,32 +153,27 @@ impl Storage for ProgramData { | |
// debug!(has_init = has_init, "declare_decl(`{}`)", i); | ||
// } | ||
|
||
let v = self | ||
.vars | ||
.entry(i.to_id()) | ||
.and_modify(|v| { | ||
if has_init && (v.declared || v.var_initialized) { | ||
trace_op!("declare_decl(`{}`): Already declared", i); | ||
|
||
v.mutated = true; | ||
v.reassigned_with_var_decl = true; | ||
v.assign_count += 1; | ||
} | ||
let v = self.vars.entry(i.to_id()).or_default(); | ||
|
||
if v.used_in_non_child_fn { | ||
v.is_fn_local = false; | ||
} | ||
if has_init && (v.declared || v.var_initialized) { | ||
trace_op!("declare_decl(`{}`): Already declared", i); | ||
|
||
v.var_initialized |= has_init; | ||
}) | ||
.or_insert_with(|| VarUsageInfo { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is problematic because this closure is not called if the analyzer called |
||
is_fn_local: true, | ||
var_kind: kind, | ||
var_initialized: has_init, | ||
no_side_effect_for_member_access: ctx.in_decl_with_no_side_effect_for_member_access, | ||
v.mutated = true; | ||
v.reassigned_with_var_decl = true; | ||
v.assign_count += 1; | ||
} | ||
|
||
..Default::default() | ||
}); | ||
// This is not delcared yet, so this is the first declaration. | ||
if !v.declared { | ||
v.var_kind = kind; | ||
v.no_side_effect_for_member_access = ctx.in_decl_with_no_side_effect_for_member_access; | ||
} | ||
|
||
if v.used_in_non_child_fn { | ||
v.is_fn_local = false; | ||
} | ||
|
||
v.var_initialized |= has_init; | ||
|
||
v.declared_count += 1; | ||
v.declared = true; | ||
|
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
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.
I see. In this case
arr
used to be marked asvar_kind
None
.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.
Yeah and that's why it was not inlined I guess