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
Duplicated identifier used when mangle is enabled #1155
Comments
Terser really can't deal with scopes of function declarations when they're inside of a block. This section of the spec isn't being properly followed. I'm thinking that this pattern should trigger the scope's I hate to learn that this ancient issue caused grief to someone. |
Note that declaring |
I've been looking around and trying different things. I can fix this but haven't decided what's the best long term fix. To fix the case of section B 3.2.1 (funcdefs in block scopes) or avoid mangling 2 things in the same function to the same name altogether, which fixes all the cases in that section? Since block scope conflicts are often causes of bugs (and incompatibility with older Safari) I'm thinking that the mangler should avoid reusing any names in the same scope. This will, though, make the output slightly larger. |
Bug report
Terser is using the same identifier for the function, and for the const defined inside the if. This produces code that can't be evaluated.
Here is a simple reproduction case:
If var1 is outside the "if", the correct identifier is used when minifying.
Used options:
Curent terser output
note the inner function n() and the const n, they clash.
The text was updated successfully, but these errors were encountered: