Skip to content

Commit

Permalink
fix(es/minifier): Set param type to unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
Austaras committed Jan 20, 2025
1 parent e222f0d commit 5ce4711
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/swc_ecma_minifier/src/program_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,12 @@ impl Storage for ProgramData {
}

v.var_initialized |= init_type.is_some();
v.merged_var_type.merge(init_type);

if ctx.in_pat_of_param {
v.merged_var_type = Some(Value::Unknown);
} else {
v.merged_var_type.merge(init_type);
}

v.declared_count += 1;
v.declared = true;
Expand Down
6 changes: 6 additions & 0 deletions crates/swc_ecma_minifier/tests/fixture/issues/8718/7/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function foo(a) {
a += 1;
a += 2;

return a;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function foo(a) {
return a += 1, a += 2;
}

0 comments on commit 5ce4711

Please sign in to comment.