You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
constdefaultMessage="hello"// write or paste code herefunctionx(x){returnx;}functiony(x,y,z){returnx;};functionabc(a){returnx(a);}functionabc2(a,x,z=defaultMessage){returny(a);}exportfunctionexample(){// output should be// return `2 2 3 3`;return`${x(2)}${y("2")}${abc(3)}${abc2("3")}`;}
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
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.7.24&code=H4sIAAAAAAAAA11PSwrCMBTc5xRDcBGhIKTL4hG8g7F9tUJsSj6YWnp3n1q%2Fu3nzY17t%2BhDRUGuSjTsKwRwJW8iOrHVSiM0GF3%2BKBOcxmMCgdg2hI0%2BiTX0dT65HVnmNCZ5i8nxVmD%2FaqHKBscD1z1GJj8ccamW%2Bdb5%2BStiglSnAVVde9zv3KzguQUF5cD7iXUDZnAdLir0C4KdcikOKCJ1LtsGBnuxSs9fQKFHuK6Zf3GrKSq9nrKZRSS0f6D68fCGtZMk0h%2BYbmjyxQlYBAAA%3D&config=H4sIAAAAAAAAA32VPY%2FbMAyG9%2FyKQHOHIkMLdL4r0OHQoUBXQbEoR1dbMkQqlyDwfy8lOx%2BX0NlsPiIpkdSr02q9Vu%2FYqB%2FrE3%2Fyz2ASQrr8swWPgcyBLYqOA2CT%2FEDqy5kSFuRMh1BN40QUmdQCFS%2FAzdfNZvZQXYwIZ4%2FZ1vvg3fE2ZxP7IQHijY2tHDL3EAg%2F%2B88sxY8CKOVb%2BzbGDkx4QrRB7QNBC0kK3MSuMwOC3pskRCk7NcljlFIUmAmsHlIcRB6sJx8D53ykFozVTbQgIJ%2BgIb8HyY1zsVtAPp5wnootbHPb1j7fecPedNmQkBMOtSW8WyHqLnok7XKQSjjBhRpMcC7uvad3OgHlFB793qMPCz35B8AV6AxiMD1IcesKx%2FO05O2eevrgeGTpKHCeb%2BmUAVouqvbeCZUtlYFEXupmApsbKJVtpO3MeKF86C1ocI5nRQiNH56anZS0XPToBMD9NU6aqgnoyy1c4OVCPME%2F%2BZQkD9i8oje0W6Z47Lexe5KgB9pF%2B2QBt4LiMk6sEodhmedggUcDrLgkYwWPIsAXgKLuql4%2BzAZfD46o2y5uRZkYeM5rE7%2FPtvEizr0J7b0IXAQ6sfa5mPrPust7eYs2dzXiSV2znlQVjfr1649%2Bef2r336%2FvBaFr9HVOI5TgtWcRPU10PVtKWM1vQjf1HXRWfwve1Qe386e5ayr8T%2FpkujBpwYAAA%3D%3D
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
The text was updated successfully, but these errors were encountered: