This issue was encountered in real code and distilled into the provided minimal example. It appears to stem from the compress feature, which is not correctly handling function redefinition and sticking to the first definition of the wrapper function.
Input code
function test(a, b) {
let wrapper = (e) => e
wrapper = (e) => (["not", e])
if (a) {
return wrapper(b)
}
return wrapper(1)
}
console.log(test(true, "bad"))
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
This issue was encountered in real code and distilled into the provided minimal example. It appears to stem from the compress feature, which is not correctly handling function redefinition and sticking to the first definition of the
wrapper
function.Input code
Config
Playground link
https://play.swc.rs/?version=1.3.32&code=H4sIAAAAAAAAA22OwQrCMBBE7%2FsVQ067EAQ%2FoP6IeEjqVgohKekGD9J%2Fr0Z60jnOvBlmanm0uWSYrsbBIwpehLeSGp41LItWDGAVDBdoj35svrpczHnoTToxT%2BBwLH1U1VrNR5PjF9voT3YW2mgseS1JT6k8uF%2Bz2tTDxXB3IrQDQID8p7cAAAA%3D&config=H4sIAAAAAAAAA22TQXLDIAxF7%2BJ1tu2iB%2BiuZ2AUEA4tRh4k0ngyuXuFY%2BM46c56fMniS1y7b7bdx7UbITPm%2BsVTErh0Hx3aAdjmMEp3UJkiD5HxdugEco9SJfymZ5GIcTk9dENIwU%2B1kqVhzMhcvzWjDJiEmw5ypl8NJReNjkQRIb3EBtiEJNhj3lItxQgjozlDbhn1b5ADU9qhIujMmGl8oMkFCZS02MocgjOWHDYQMloJZ9wkWkMlibWx1skMHR5L31f37ko8QywgrRZeZhv0jy3vRIHF%2BJL4Ce06vaP7JRdV8CajlJxWzTeFtPPhB1H7jMCcYMAtc%2BZe57BX%2Bn9UIXkdokyN6oS3rhL2ejkTgm83rF1jlrC5ldEVi%2FWGdiu%2BwN2FODg06L263ZL5N4g9bcVkGpF8C9U18NsM7qFZ92lP6wq8wE%2FtSh7HsfAB5PTMeBqOFF9KDCgnci9YjRB6hlm39zI%2B05Icqs3oHg4K17CtqQ5fyMT61FafdSE0x%2FSRjm199UUOkPq2lrcKyJUKrrN581N9727b61zXib8W4VzoD8zDcjEPBAAA
Expected behavior
The compiled code should log
["not", "bad"]
.Actual behavior
It outputs
"bad"
.Version
1.3.32
Additional context
No response