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
This is the expected behavior and it aligns to terser.
In this situation, JS behavior can be divided into two categories
In es module and other environment where top level var can shadow anything, due to var hoist, the code should act like
vara=undefined;consttext=a("Hello world");
In other environment where top level may not shadow global provided vars, the code should act like
vara=undefined;consttext=btoa("Hello world");
However, there's no standardized list of what runtime may provide, so we only respect this behavior to a very limited common subset namely undefined and NaN.
Describe the bug
The minifier incorrectly renames identifiers if the variable name is the same as the value's identifier, eg
var btoa = btoa;
becomesvar l = l;
Input code
Config
No response
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.100&code=H4sIAAAAAAAAAytLLFJIKslPVLAFU9a8XLxcyfl5xSUKJakVJVBRDSWP1JycfIXy%2FKKcFCVNoCIAtAg4yzcAAAA%3D&config=H4sIAAAAAAAAA32QTQ6CMBCF95yCzNoFsjDGO3gGM6kDKba06RQiIdzd8lOESNy0nfe%2B6WRen6QpVCzglvbhGQqLjsmtdVC4qz2%2BgwIkNLJw0no4Rbfi0SpQMU3SMDvg0ZXkpy7OszxfOkAZwxQ7Fk3LWhbddqYw2jpi3oMjinWpaIOOo4xV1JIKqnfNygbnRWQfQiFzjZp%2BfotE8de1TrboKdzGHkGSrgcqY4FOnrNdOCGeJJ5TUKDNs9nsA76zNId2gS8U84nrgeR7bBy1ZPgAtz%2FrR8kBAAA%3D
SWC Info output
No response
Expected behavior
The expected output should be something like:
Actual behavior
The variable's value becomes the variable's new name, causing incorrect behaviour
Version
1.3.100
Additional context
No response
The text was updated successfully, but these errors were encountered: