unary negation handling is broken in ->JavaScript
littleredcomputer opened this issue · comments
Colin Smith commented
Minimal repro:
user=> (->JavaScript (simplify (* -2 (+ 'x 'y))))
"function(x, y) {\n return -2 * x -2 * y;\n}"
This may work, but it looks like it has promoted the -2 from unary negation to binary subtract, which I find suspicious. Can this be correct in all cases?
Sam Ritchie commented
Oh yeah, another one I ran into had to do with dashes being illegal... we need to transform them to underscores.
Colin Smith commented
I think we may have been getting away with this, but I'm going to make it a bit more principled instead of just looking for an initial hyphen in the string rep of the next term in the sum. Also, will make it work for -k
instead of just -1
Sam Ritchie commented
Just checked to see if this was fixed by CSE and it looks like it's still an issue.