Open Abhiroop opened 3 years ago
data List a where {
Nil : List a;
Cons : a -> List a -> List a
}
v0 = let (Cons v1 _) = Cons 1 Nil in v1 + v1 : Int
main = v0 : n
The issue seems to be in the monomorphiser which is unable to monomorphise the main
function. Notice the polymorphic type of the main
.
It eventually eliminates the main
function assuming there is no call to main
and hence it is safe to remove.
The issue is probably in the type checker, where it doesn't unify the type of main
and baz
properly.
Smaller test case the replicate the same bug:
baz = let x = 1
in x
main = baz
The issue is probably that the type of the entire let expression is placed in the environment after the let expression has returned (and thus returned the typing environment to the same state), so the type of baz
will become the type schema forall b . b
, where it should be forall () . b
. When main
looks up the type of baz
, b
will be instantiated to a fresh type variable.
This program fails:
Fails with