haxe-formatter
haxe-formatter copied to clipboard
expressionIf detection in array comprehension
Describe the bug
expressionIf
detection seems to fail here (works if the if
is prefixed with return
directly):
Input file
class Main {
static function main() {
return [
for (meta in node.metadata) {
var child = node.children[meta - 1];
if (child == null) 0 else value(child);
}
].sum();
}
}
Broken output
class Main {
static function main() {
return [
for (meta in node.metadata) {
var child = node.children[meta - 1];
if (child == null)
0
else
value(child);
}
].sum();
}
}
Similar:
class Main {
static function main() {
[
if (foo) bar else foo,
if (foo) bar else foo,
if (foo) bar else foo,
if (foo) bar else foo,
if (foo) bar else foo
]
}
}
becomes:
class Main {
static function main() {
[
if (foo)
bar
else
foo,
if (foo)
bar
else
foo,
if (foo)
bar
else
foo,
if (foo)
bar
else
foo,
if (foo)
bar
else
foo
]
}
}