roc/crates/compiler/constrain/src
Ayaz Hafiz b4216a26a5
Force occurs check for introduced types after checking annotated bodies
The current type inference scheme is such that we first introduce the
types for annotation functions, then check their bodies without
additional re-generalization. As part of generalization, we also perform
occurs checks to fix-up recursive tag unions.

However, type annotations can contain type inference variables that are
neither part of the generalization scheme, nor are re-generalized later
on, and in fact end up forming a closure of a recursive type. If we do
not catch and break such closures into recursive types, things go bad
soon after in later stages of the compiler.

To deal with this, re-introduce the values of recursive values after we
check their definitions, forcing an occurs check. This introduction is
benign because we already generalized appropriate type variables anyway.
Though, the introduction is somewhat unnecessary, and I have ideas on
how to make all of this simpler and more performant. That will come in
the future.
2022-11-24 10:05:28 -05:00
..
builtins.rs Remove unused functions 2022-11-11 21:16:24 -06:00
expr.rs Force occurs check for introduced types after checking annotated bodies 2022-11-24 10:05:28 -05:00
lib.rs correct formatting and removed duplicate image 2022-11-03 20:02:10 +11:00
module.rs [skip-ci] Fix borrow issues in constraining 2022-11-11 21:16:22 -06:00
pattern.rs Remove Cells from Types 2022-11-15 09:00:16 -06:00