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
Mangle function name duplicate with the parameter name #6819
Comments
Related issue?#6730 |
I didn't know that a rest parameter behaves differently than a normal parameter... |
In this file and the closure scope, |
@iheyunfei Do you have any idea to fix this? |
edited: I just check it, it's not right. Let me do some digging. Yeah. A simple way is adding a line like fn visit_fn_decl(&mut self, f: &FnDecl) {
self.add_decl(f.ident.to_id(), true);
self.with_fn_scope(|v| {
+ v.add_usage(f.ident.to_id());
f.function.decorators.visit_with(v);
f.function.params.visit_with(v);
// WARN: Option<BlockStmt>::visit_mut_children_wth
// is not same with BlockStmt::visit_mut_children_wth
v.visit_fn_body_within_same_scope(&f.function.body);
})
} in swc/crates/swc_ecma_transforms_base/src/rename/analyzer/mod.rs Lines 270 to 280 in 179a5f8
|
Thank you! I'll try |
Oh, I think it will regress all cases. |
I'll check for rest and apply your patch 😄 |
The idea is correct in general. But the code I provided seems wrong. We need to create fake usages for names that could be conflicting with others. I also look out Terser, the outputs are
|
It was correct for |
Thank you! I fixed it by creating a fake usage |
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
output code:
run in Safari throw error:
But it works in chrome...
Input code
Config
Playground link
https://play.swc.rs/?version=1.3.26&code=H4sIAAAAAAAAA0utKMgvKlFIK81LLsnMz1OIj3cOcnUMcY13jQiIj9fQVKjmUlAoSi0pLcpDKALKaejp6SUWpRdDFIAAVFFZYk5pqjVQrNaaq5YLAMflGI9fAAAA&config=H4sIAAAAAAAAA22PQQrCQAxF75J1Fyoo0hO48QwS6q%2BMTmdCEqVFenenUi2Cq4T%2F85O8J12tofpJwmrQqbMhOfdUkw8CazSIU0VuRWo5GsaK0Ds0cTwgCtSodr2jzLBe4CUJ26zW25KKORvmXEVdSKEdphtN7kRhtlicLhGT5VkiHohf6wbIqYlslriD%2FertH000PNhRapbFCth%2Fe%2BOWNaxXH6KxMHX5fJ8%2FKNxviB2Ny9OfNXacByfm8QVyauLJQAEAAA%3D%3D
Expected behavior
Actual behavior
No response
Version
1.3.26
Additional context
No response
The text was updated successfully, but these errors were encountered: