Closed felixSchl closed 6 years ago
Fixed by running a pass over the AST that hoists variable declarations to the top of blocks (https://github.com/pure-c/pure-c/blob/7bc2a52ce211b5ac27c620d263b287a8933a48b7/src/Language/PureScript/CodeGen/C.purs#L742-L804)
PureScript test "passing/1991.purs" is not passing because the currently generated C code redefines local variables (#12)
Without the
inlineVariables
optimization pass in the PureScript JS codegen, it spits out code looking similar to this:JavaScript doesn't care that e.g.
f1
gets redefined at will, but we're not so fortunate in C. I think we should be able to generate unoptimized code that still compiles. We could forward declare variable introductions on a per-block level and then assign to them later. This rewrite pass would run on the initially generated AST.