After fixing simplify in 2.10.2, the simplification for nested if statements seems to become wrong.
Original Code
function foo () {
if (bar) {
if (baz) {
const a = aa()
}
} else {
bb()
}
}
Expected Behavior
It should be and is translated in 2.10.1 to:
function foo () {
if (bar) {
if (baz) {
const a = aa();
}
} else
bb();
}
Current Behavior
But it is translated in 2.10.2 to:
function foo () {
if (bar)
if (baz) {
const a = aa();
}
else
bb();
}
The missing braces in the then branch of the first if makes the else branch matches to the second if. As a result, the program goes wrong.
And interestingly, if I use ES5’s var to declare the variable, everything’s good. The let and const would result in a bad code.
Steps to Reproduce
Just try above code with default configuration.
Your Environment
- Obfuscator version used: 2.10.2
- Node version used: 12.16.1
Minimal working example that will help to reproduce issue
See above.
After fixing simplify in 2.10.2, the simplification for nested if statements seems to become wrong.
Original Code
Expected Behavior
It should be and is translated in 2.10.1 to:
Current Behavior
But it is translated in 2.10.2 to:
The missing braces in the then branch of the first if makes the else branch matches to the second if. As a result, the program goes wrong.
And interestingly, if I use ES5’s
varto declare the variable, everything’s good. Theletandconstwould result in a bad code.Steps to Reproduce
Just try above code with default configuration.
Your Environment
Minimal working example that will help to reproduce issue
See above.