-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrongly transform function Infinity to 1/0 #8465
Comments
Declare unwritable and unconfigurable global variable in top level is a |
#8336 is easily fixable -- just don't rename top level declaration. But this issue is not -- the correct semantic, ignoring that error, is 1/0. |
I was wrong. ESM top level var is not in global context, so they can safely shadow undefined/Infinity/NaN. |
…` correctly (#8471) **Description:** For following code ```js var NaN = 1 console.log(NaN) ``` Result would be |Envirnoment|Result| |-|-| |Non strict script(browser, nodejs repl)|NaN| |Non strict script(nodejs script)|1| |Strict script(browser, nodejs repl)|runtime error| |Strict script(nodejs script)|1| |ESM|1| So SWC choose to behave like browser in script mode and confirm to esm standard. **Related issue:** - Closes #8465
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
Infinity is wrongly transformed to 1/0
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.100&code=H4sIAAAAAAAAA0srzUsuyczPU%2FDMS8vMyyyp1NCs5lIAguT8vOL8nFS9nPx0DfWKigp1TWuuWq7UioL8ohKFlNS0xNKcErgmawCsssEKRwAAAA%3D%3D&config=H4sIAAAAAAAAA32US5LjIAyG932KlNe9nVnMAXo3Z6AICIc0Ri4k0nF15e4jY%2BcxHTk7W59%2BCSSh77fdrjuS6%2F7svuVTfkZbCMrtXyw0ZbZnsXTgBkuuxJG79ys90oyCTQTNdFlIx7b0wE1Fv1b3LiESXN1X2xBzDNNjQofDWIDowSZWiVcHyEz%2F61dW8GsGXOqjfY%2BYwOYXxFgyMTP0ULTADlOyI4E52aJEmU9qSyTUUsywMngzFhxVnn3kiFlyPlMP1huHHhQUCziOJ9BkkktkmeR6yn0a9rCvfd%2Ba%2FEMNJ5uqZSUnnFtL5LRK1ANGYhNq1kq4wI0aLHAt7k9lDKYA15KfdUeMeaMnnwBSgWSJsh1Ai9s8gszTljq8VMYcZGR5UrjMt3bLDL0U1cQYlMrOlYHCUetmAV8dzJV12nFWvFE%2Bih4MhCCzooSmr8juoCXlaQQMCpD%2B2qBN1QLM7RVu8PlBvMAfckvWB2z1GCwftilNwx7TiwQD8AH9CwdpBeM2LrIlzuM2r9mDjAZ41aVSA89LQB4Ao0ltWT7NhjwPiWj6hPv7mlgdLrclPNjc39%2F7soffVoduQF8bXDf83N9lL%2F%2Fu7k7XLXw7eBfp71XZkl7%2BAVPL6HotBgAA
SWC Info output
1.3.100
Expected behavior
don't turn to 1/0 like terser
Actual behavior
Version
1.3.100
Additional context
No response
The text was updated successfully, but these errors were encountered: