I'm currently not aware of the current type error diagnosis system in Roc, yet I expect it to be different than what I'll mention below.
I'll describe the idea in short, but the ideas are from a lecture I had by Jurriaan Hage, see the slides: https://www.cs.uu.nl/docs/vakken/mapa/downloads/type-error-diagnosis.pdf
The idea is to avoid inferring types in a left to right fashion (assume a type and use that in the following inference) and instead construct constraints to which the types have to adhere and solve those afterwards. With the goal of error messages with no order bias (as we don't evaluate the constraints in any particular order), heuristics for common mistakes, and other error message improvements (see slides).
Fascinating :)
roc also uses a constraint solver. Certain types are forced (like the condition of an if-then-else) and those reasons are recorded. The constraints have a bunch of extra context too and always store the region that they were generated from, so we can display code snippets
I believe order is usually not a problem, but there might be some edge cases where it is
Last updated: Jun 16 2026 at 16:19 UTC