Problem with unsaturated uncurrying
Opened this issue · 0 comments
Hey,
I've hit an issue where the uncurrying optimization finds an unsaturated call to a function that was already uncurried, wraps a new function around it, but the argument of that function shadows another argument to the function call.
We start with this code:
var teacherCards = function (v) {
return function (v1) {
if (v1 instanceof Data_Async.Done) {
return VirtualDOM_HTML.div([ ])(Data_Functor.map(Data_Functor.functorArray)(teacherCard(v))(v1.value0));
};
};
};
The resulting code ends up like this:
var _teacherCards_uncurried = function (v, v1) {
if (v1 instanceof Done$1) {
return div$1([])(function (dict) {
return dict.map;
}(functorArray)(function (v) {
return _teacherCard_uncurried(v, v); /// the variable "v" is being shadowed!!!
})(v1.value0));
}
};
teacherCard was uncurried before, and has two arguments:
var _teacherCard_uncurried = function (today, v) {
/* implementation */
}
The problem now arises because the second argument in _teacherCard_uncurried
is called "v". We're reusing the name of this variable in
body = {
type: "FunctionExpression",
id: null,
// TODO make a copy of the params ?
params: uncurried.params[i], // <--- RIGHT HERE
body: {
type: "BlockStatement",
body: [{
type: "ReturnStatement",
argument: body
}],
directives: []
}
};
and then via the flattened
array this is added to the resulting arguments of the call to _teacherCard_unCurried. This part I don't fully understand (yet), so that's why I'm making this issue and writing it all down instead of just fixing it :P.