1
1
mirror of https://github.com/tweag/nickel.git synced 2024-11-10 10:46:49 +03:00

Fix wrong apparent type for lists

The apparent type of list was determined to be `Inferred(List)`, but this
type is actually less precise that the type that would be inferred,
which can be `List Num` for example. The typechecker was wrongly giving
less precise type to binding of the form `val = [ .. ]` inside
statically typed code.
This commit is contained in:
Yann Hamdaoui 2021-02-16 16:49:24 +01:00
parent 9592d7935b
commit 7c2059cc5f

View File

@ -810,7 +810,7 @@ pub fn apparent_type(t: &Term, envs: Option<&Envs>) -> ApparentType {
Term::Sym(_) => ApparentType::Inferred(Types(AbsType::Sym())),
Term::Str(_) | Term::StrChunks(_) => ApparentType::Inferred(Types(AbsType::Str())),
Term::List(_) => {
ApparentType::Inferred(Types(AbsType::List(Box::new(Types(AbsType::Dyn())))))
ApparentType::Approximated(Types(AbsType::List(Box::new(Types(AbsType::Dyn())))))
}
Term::Var(id) => envs
.and_then(|envs| envs.get(id))