This looks a lot more complicated than it ought to. The real bug was a mishandling of local polymorphic functions in monomorphisation. I reasoned that there is no reason monomorphisation should ever encounter those - we should lambda lift those before we monomorphise. However, that created the need for a bunch of other modifications, including a new (very small) pass (ApplyTypeAbbrs) that runs just after defunctorisation.
IT is overall a conceptual simplification, but the code changes look quite large for such a small bug.
This looks a lot more complicated than it ought to. The real bug was a mishandling of local polymorphic functions in monomorphisation. I reasoned that there is no reason monomorphisation should ever encounter those - we should lambda lift those before we monomorphise. However, that created the need for a bunch of other modifications, including a new (very small) pass (ApplyTypeAbbrs) that runs just after defunctorisation.
IT is overall a conceptual simplification, but the code changes look quite large for such a small bug.