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

es/minifier: assignmentexpr can be lowered to just binary expression when inlining with no further accesses #10228

Open
Le0Developer opened this issue Mar 19, 2025 · 1 comment

Comments

@Le0Developer
Copy link

Describe the feature

window.test = function (foo) {
    foo -= 1023;
    return Math.pow(2, foo);
}

compiles to

window.test=function(t){return Math.pow(2,t-=1023)};

the t-=1023 can be lowered to t-1023 here, since there are no other accesses.
This could be unsafe if there are closures, but that should be possible to guarantee statically.

Babel plugin or link to the feature description

No response

Additional context

Playground

@Austaras
Copy link
Member

It's definitely possible but I doubt if anyone really write code like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants