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

Wrong code generated for while statement, edgecase #922

Closed
msn0 opened this issue Oct 26, 2018 · 1 comment
Closed

Wrong code generated for while statement, edgecase #922

msn0 opened this issue Oct 26, 2018 · 1 comment

Comments

@msn0
Copy link
Contributor

msn0 commented Oct 26, 2018

Describe the bug

The falsy while statement should not remove variable declarations.

To Reproduce

Minimal code to reproduce the bug

function a() {
  ++i;
  while (false) {
    var i = meow();
  }
}

Actual Output

If there is no Error thrown,

function a(){
  ++i;
}

Expected Output

function a(){
  ++i;
  var i;
}

Configuration

How are you using babel-minify?

babel-minify CLI

babel-minify version: 0.5.0

babel version : 7.0.0-beta.49

babel-minify-config: default

Possible solution

Looks like path should not be removed but instead replaced with extracted variables.

@msn0
Copy link
Contributor Author

msn0 commented Oct 26, 2018

I think I've got a solution for that. I'll create a PR soon.

msn0 added a commit to msn0/minify that referenced this issue Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant