Open
Description
Describe the bug
When a function parameter has a default value, and that parameter is not used, the parameter (and consequently the whole function) are not optimized away.
Input code
const defaultMessage = "hello"
// write or paste code here
function x(x) { return x; }
function y(x, y, z) { return x; };
function abc(a) { return x(a); }
function abc2(a, x, z = defaultMessage) { return y(a); }
export function example() {
// output should be
// return `2 2 3 3`;
return `${x(2)} ${y("2")} ${abc(3)} ${abc2("3")}`;
}
Config
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false
},
"target": "es2022",
"loose": false,
"minify": {
"compress": {
"arguments": false,
"arrows": true,
"booleans": true,
"booleans_as_integers": false,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": true,
"directives": true,
"drop_console": false,
"drop_debugger": true,
"evaluate": true,
"expression": false,
"hoist_funs": false,
"hoist_props": true,
"hoist_vars": false,
"if_return": true,
"join_vars": true,
"keep_classnames": false,
"keep_fargs": true,
"keep_fnames": false,
"keep_infinity": false,
"loops": true,
"negate_iife": true,
"properties": true,
"reduce_funcs": false,
"reduce_vars": false,
"side_effects": true,
"switches": true,
"typeofs": true,
"unsafe": false,
"unsafe_arrows": false,
"unsafe_comps": false,
"unsafe_Function": false,
"unsafe_math": false,
"unsafe_symbols": false,
"unsafe_methods": false,
"unsafe_proto": false,
"unsafe_regexp": false,
"unsafe_undefined": false,
"unused": true,
"const_to_let": true,
"pristine_globals": true,
"passes": 7
},
"mangle": false,
},
"transform": {
"constModules": {"globals": {"debug": {"IS_DEV_MODE": "false"}}}
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
Playground link (or link to the minimal reproduction)
SWC Info output
I'm only using the playground
Expected behavior
Behavior without the default value in the function parameter
When a parameter is unused, it shouldn't matter if it has a default value or not.
Actual behavior
function is not optimized away
Version
1.7.24 and newer (didn't test older)
Additional context
No response