Skip to content
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

Name mangler of minifier should understand block scoping #5766

Closed
kdy1 opened this issue Sep 6, 2022 · 3 comments · Fixed by #6670
Closed

Name mangler of minifier should understand block scoping #5766

kdy1 opened this issue Sep 6, 2022 · 3 comments · Fixed by #6670

Comments

@kdy1
Copy link
Member

kdy1 commented Sep 6, 2022

While working on #5763, I found that terser reuses variable names in more cases compared to swc.

Input

function test(foo, bar) {
    try {
        const bar = {};
        throw "PASS";
    } catch (error) {
        return bar(error);
    }
}
console.log(test(null, (x) => x));

Current

function n(n, o) {
    try {
        const t = {};
        throw "PASS";
    } catch (c) {
        return o(c);
    }
}
console.log(n(null, (n)=>n));

terser output

function n(n, o) {
    try {
        const n = {};
        throw "PASS";
    } catch (n) {
        return o(n);
    }
}
console.log(n(null, (n) => n));
@kdy1 kdy1 added this to the Planned milestone Sep 6, 2022
@kdy1 kdy1 self-assigned this Sep 6, 2022
@kdy1 kdy1 removed their assignment Sep 19, 2022
@hyf0
Copy link
Contributor

hyf0 commented Dec 15, 2022

@kdy1 Are there any traps to implement this? Or just improving the analysis here would be good enough?

@kdy1
Copy link
Member Author

kdy1 commented Dec 15, 2022

There's no trap and improving the analyzer is the all of the required work

@swc-bot
Copy link
Collaborator

swc-bot commented Feb 10, 2023

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

3 participants