From b2161e3148e40cec252abb0ef33538b797954579 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 22 Apr 2019 09:42:30 -0700 Subject: wasm2js: fix printing of negated negative constants (#2034) It is invalid to print --5, we need to add a space - -5 so that it is valid JS to parse. --- src/emscripten-optimizer/simple_ast.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/emscripten-optimizer/simple_ast.h') diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h index 969277466..ded8af5f4 100644 --- a/src/emscripten-optimizer/simple_ast.h +++ b/src/emscripten-optimizer/simple_ast.h @@ -986,6 +986,9 @@ struct JSPrinter { } void printNum(Ref node) { + if (node->getNumber() < 0 && buffer[used-1] == '-') { + emit(' '); // cannot join - and - to --, looks like the -- operator + } emit(numToString(node->getNumber(), finalize)); } -- cgit v1.2.3