Skip to content

Commit

Permalink
Fixes babel#922, extractVars instead of path removal
Browse files Browse the repository at this point in the history
  • Loading branch information
msn0 committed Oct 26, 2018
1 parent 6b1c350 commit f8d2cbc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function a() {
++i;
while (false) {
var i = meow();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function a() {
++i;
var i;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// while
while (true) {
bar();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ module.exports = ({ types: t, traverse }) => {
const test = path.get("test");
const result = evaluate(test, { tdz: this.tdz });
if (result.confident && test.isPure() && !result.value) {
path.remove();
path.replaceWithMultiple(extractVars(path.get("body")));
}
},

Expand Down

0 comments on commit f8d2cbc

Please sign in to comment.