FStarLang / FStar

A Proof-oriented Programming Language
https://www.fstar-lang.org
Apache License 2.0
2.65k stars 232 forks source link

Implicits are too eager #3339

Open mtzguido opened 4 days ago

mtzguido commented 4 days ago

Old issue, but something I'd like to revisit now.

In the snippet below, we want to make a list of functions of some_ty, just like f1, but trying to write this list triggers an implicit instantiation for f1 and does not check. This should not happen IMO since the expected type for that position is some_ty, which has an implicit.

open FStar.List.Tot
let some_ty = (#x:int) -> l:(list int){length l == x} -> bool
let f1 : some_ty = fun _ -> true
let funcs : list some_ty = [f1]     

Workarounds are annotating f1 <: some_ty or eta expanding (fun #x -> f1 #x).