Bug
Version (complete output of terser -V)
terser 4.1.4
Complete CLI command or minify() options used
terser --compress --mangle
terser input
function test(foo, bar) {
let model = false;
if (model) {
} else {
model = true;
}
try {
const bar = {};
} catch (error) {
bar.dispose();
}
}
terser output or error
function test(t,c){let s=!1;s||(s=!0);try{const t={}}catch(c){t.dispose()}}
Expected result
Within the catch block, it should be c.dispose() and not t.dispose()! After all, the wrong parameter is being called dispose on.
I was able to reproduce this in 4.0.0.
One note, because it tripped me off initially:
It is expected to be c.dispose() because of function test(t,c), not because of catch(c).
The use of the variable name c in the catch is actually wrong.
Thank you very much for the report.
This still reproduces with Terser 4.1.4.
Probably with the latest version too. I'll see what I can do this week.
Thanks, I just recently replaced uglify-es with latest terser for VSCode and it would be great to get that fix in eventually 馃憤
Very subtle bug, as it revealed a slight problem in the AST design.
Oh great, thanks for fixing it.