From c07329b4ef4c68cf8f0f56359e664fd27e1fe96b Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Sat, 4 Feb 2017 18:32:51 -0800 Subject: [PATCH] Do not attach comments to EmptyStatement (#599) Since we don't print EmptyStatement, we don't want to attach comments to them. I've tried actually printing the EmptyStatement but it messes up a ton of other things. --- src/comments.js | 2 +- tests/flow/binding/__snapshots__/jsfmt.spec.js.snap | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/comments.js b/src/comments.js index 67d40de3..35e80fa0 100644 --- a/src/comments.js +++ b/src/comments.js @@ -28,7 +28,7 @@ function getSortedChildNodes(node, text, resultArray) { util.fixFaultyLocations(node, text); if (resultArray) { - if (n.Node.check(node)) { + if (n.Node.check(node) && node.type !== "EmptyStatement") { // This reverse insertion sort almost always takes constant // time because we almost always (maybe always?) append the // nodes in order anyway. diff --git a/tests/flow/binding/__snapshots__/jsfmt.spec.js.snap b/tests/flow/binding/__snapshots__/jsfmt.spec.js.snap index 239ca9dc..495adf45 100644 --- a/tests/flow/binding/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/binding/__snapshots__/jsfmt.spec.js.snap @@ -416,13 +416,13 @@ function var_var() { function function_toplevel() { function a() {} - function a() {} + function a() {} // OK } function function_block() { { function a() {} - function a() {} + function a() {} // error: name already bound } }