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

if expression not minified correctly #12

Closed
adoxa opened this issue Jun 5, 2024 · 5 comments
Closed

if expression not minified correctly #12

adoxa opened this issue Jun 5, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@adoxa
Copy link

adoxa commented Jun 5, 2024

  • Minify Version: v11.2.0
  • Node Version: v20.13.1
  • OS: Windows 10 64-bit

This expression:

if (var1 || (var2 && var3)) {
   console.log("test")
}

incorrectly minifies to:

var1||(var2&&var3)&&console.log('test');

when it should be:

(var1||var2&&var3)&&console.log("test");

as it is when using the terser type.

@coderaiser coderaiser added the bug Something isn't working label Jun 5, 2024
coderaiser added a commit to coderaiser/putout that referenced this issue Jun 5, 2024
@coderaiser
Copy link
Contributor

Thank you! Just fixed and landed in v3.12.0 🎉 .

Is it works for you?

@adoxa
Copy link
Author

adoxa commented Jun 5, 2024

The test file works, but the actual code still does not. I'll see if I can come up with another test case later...

@adoxa
Copy link
Author

adoxa commented Jun 5, 2024

Turns out it was just a simple matter of adding another condition:

if (var1 || (var2 && var3)) {
   fn1();
   if (var4) {
	   fn2();
   }
}

becomes:

var1||(var2&&var3)&&(fn1(),var4&&fn2());

where the brackets are missing, again.

@coderaiser
Copy link
Contributor

Landed in v3.12.1 🎉.

Is it works for you?

@adoxa
Copy link
Author

adoxa commented Jun 6, 2024

Yep, that got it.

@adoxa adoxa closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants