spread call miscompilation
edef1c opened this issue · comments
edef commented
coco: f ...[x for x of [1, 2, 3]]
expected compilation:
var x;
f.apply(null, [(function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = [1, 2, 3]).length; i$ < len$; ++i$) {
x = ref$[i$];
results$.push(x);
}
return results$;
}())]);
actual compilation:
var x;
f((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = [1, 2, 3]).length; i$ < len$; ++i$) {
x = ref$[i$];
results$.push(x);
}
return results$;
}()));
f ...([x for x of [1, 2, 3]])
compiles to the correct JS.
Satoshi Murakami commented
It's an optimization. f ...[a, b]
is unrolled to f a, b
pre-compile.
edef commented
A mis-optimisation, though?
One of them calls a function with a single array argument, the other calls a function with multiple arguments.
ven commented
.apply takes an array of arguments.