mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 00:32:15 +03:00
fix(es/minifier): Track if a var is used with in
(#9508)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/9499
This commit is contained in:
parent
da529304fe
commit
7d6269e3b8
6
.changeset/sour-pumpkins-rescue.md
Normal file
6
.changeset/sour-pumpkins-rescue.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
swc_ecma_usage_analyzer: patch
|
||||
swc_core: patch
|
||||
---
|
||||
|
||||
fix(es/minifier): Track if a var is used with `in`
|
@ -11347,6 +11347,19 @@ fn issue_9184_2() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_9499() {
|
||||
run_default_exec_test(
|
||||
"
|
||||
const o = {'a': 1, 'b': 2};
|
||||
function fn() {
|
||||
return 'a' in o;
|
||||
}
|
||||
console.log(fn());
|
||||
",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_9356() {
|
||||
run_default_exec_test("console.log((function ({ } = 42) { }).length)");
|
||||
|
@ -340,6 +340,7 @@ where
|
||||
if e.op == op!("in") {
|
||||
for_each_id_ref_in_expr(&e.right, &mut |obj| {
|
||||
let var = self.data.var_or_default(obj.to_id());
|
||||
var.mark_used_as_ref();
|
||||
|
||||
match &*e.left {
|
||||
Expr::Lit(Lit::Str(prop)) if prop.value.parse::<f64>().is_err() => {
|
||||
|
Loading…
Reference in New Issue
Block a user