Ampersand bugs
edemaine opened this issue · comments
if/then
e.children = e.children.map
if & is e.block then block else &
// ↓↓↓
e.children = e.children.map(($) =>
$ === e.block ? block : ($1) => $1
);
I expected this to be a single function, but each &
gets treated as its own function wrapper. By contrast, ?:
works fine:
e.children = e.children.map(($) =>
$ === e.block ? block : $
);
Assignment
The docs say that we don't lift beyond an assignment, but I find this not to be the case:
f = & + 1
// ↓↓↓
($) => (f = $ + 1);
I ran into the first one the other day, but in a slightly different way so I didn't file an issue about it:
arr.map
if &.x
foo
else if &.y
bar
else
baz
arr.map(($) =>
$.x
? foo
: ($1) => {
if ($1.y) {
return bar;
} else {
return baz;
}
}
);