`&` doesn't always work in `if` statement
bbrk24 opened this issue · comments
For some reason, these generate invalid JS:
if & then x // $ => if ($) x
return if & then x // $ => return ($ ? x : void 0)
While these do not:
foo if & then x // foo(($) => ($ ? x : void 0))
f := if & then x // const f = ($) => ($ ? x : void 0)
return if & then x
is fixed via #1177.
The issue with if & then x
is that it's an if
statement instead of an expression. I guess in these situations we need to unbare the block (add braces) and call insertReturn
. An example where this is actually useful:
=>
if & then y