Open evincarofautumn opened 10 years ago
Source locations would be much more helpful if Type.setOrigin
were used more liberally & consistently during inference. Essentially, whenever we have a type and we discover that it’s related to some syntax element, such as a type signature or local variable, we should push the origin of that element through the type.
The Compositional Type Checking system written by Georgö Érdi may be of use in this area. You can see a reference implementation in my experimental js type checker
That looks like it will be useful, thanks!
I’m probably not going to change the major structure of the typechecker again for a little while, though. This project is still recovering from the last time I decided to redo it. :P
The current system of type origins is better than nothing, but produces messages that are rather noisy, without much actionable information or helpful source locations. It would be better to keep track of why a type deduction was made during inference, and report the chain of reasoning that led up to an inconsistency, proof-style.
I think this can be done relatively straightforwardly during unification.