spread call miscompilation
edef1c opened this issue · 3 comments
edef1c 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.
satyr commented
It's an optimization. f ...[a, b]
is unrolled to f a, b
pre-compile.
edef1c commented
A mis-optimisation, though?
One of them calls a function with a single array argument, the other calls a function with multiple arguments.
vendethiel commented
.apply takes an array of arguments.