summaryrefslogtreecommitdiff
path: root/src/emscripten-optimizer
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-04-17 10:34:54 -0700
committerGitHub <noreply@github.com>2019-04-17 10:34:54 -0700
commitf75cf7fe9a70ec7041f758f061ac45deed18f4ab (patch)
tree6388084bdb173b613e57cc0661d58ac7de45d690 /src/emscripten-optimizer
parent4a1a935ff0e30c9e46f4b7469488a5b6ffee2714 (diff)
downloadbinaryen-f75cf7fe9a70ec7041f758f061ac45deed18f4ab.tar.gz
binaryen-f75cf7fe9a70ec7041f758f061ac45deed18f4ab.tar.bz2
binaryen-f75cf7fe9a70ec7041f758f061ac45deed18f4ab.zip
Fix if else JS printing when if body is a labelled block (#2017)
Before, we'd print if (..) label: { .. }; else .. But that is wrong, as it ends the if too early. After this, we print if (..) label: { .. } else .. The bug was we checked if the if body was a block, but not if it was a labelled block.
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r--src/emscripten-optimizer/simple_ast.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h
index f38377e70..777dfc77f 100644
--- a/src/emscripten-optimizer/simple_ast.h
+++ b/src/emscripten-optimizer/simple_ast.h
@@ -635,7 +635,10 @@ struct JSPrinter {
}
bool isBlock(Ref node) {
- return node->isArray() && node[0] == BLOCK;
+ if (node->isArray() && node[0] == BLOCK) return true;
+ // Check for a label on a block
+ if (node->isArray() && node[0] == LABEL && isBlock(node[2])) return true;
+ return false;
}
bool isIf(Ref node) {