Open mtzguido opened 4 years ago
Seems related to #604 since it works correctly without a val
.
Tracked this down to lookup_qname
which was calling inst_tscheme
on recursive definitions, when it should have really been returning the exact same set of names on which the function is being defined. Then, typechecking last
was returning something like last<?1>
of type#a:Type u#some_univ_name -> l:list a{Cons? l} -> a
, with ?1
totally unrelated. This happens since last
is pushed into the environment as a Binding_lid
which is already instantiated, so calling inst_tscheme
on it does nothing on its type, but corrupts the concrete universes.
I fixed this on master already, but leaving it open since 1) I couldn't really add a regression test, since it was silently succeeding anyway; and 2) for better tracking of universe uvars 3) maybe removing the defaulting to zero (in any case, it shouldn't be done in the normalizer).
This code:
Is checked by F* into:
Note how the function is universe polymorphic, but is instead applied to
u#0
in the recursive call. The uvar actually remains unresolved, and a line inFStar.TypeChecker.Normalize.norm_universe
sets it to 0:https://github.com/FStarLang/FStar/blob/272994209aaef5afd439a684eca389b952364525/src/typechecker/FStar.TypeChecker.Normalize.fs#L187-L191
I noticed this while trying to remove that shady line.