Skip to content

"if" condition is incorrectly omitted after minify #810

@runtarm

Description

@runtarm

Input Code

if (false) {
  var bar = true;
}
if (bar) {
  alert('bug!');
}

Actual Output

var bar;alert('bug!');

Expected Output

var bar;bar&&alert('bug!');

Details

The if condition is incorrectly removed. The logic is changed.

I know that putting var inside a block scope is definitely a bad practice. I've just tried to minify some legacy codes and encountered this critical issue.

Example: See it here in repl

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions