diff --git a/base/src/types/mod.rs b/base/src/types/mod.rs index 1da2311de1..df0bfa9081 100644 --- a/base/src/types/mod.rs +++ b/base/src/types/mod.rs @@ -1653,6 +1653,12 @@ pub trait TypeExt: Deref::Id, Self>> + Clone + S Self: fmt::Display, Self::Id: fmt::Display, { + // If the alias was just hiding an error then any application is also an error as we have + // no way of knowing how many arguments it should take + if let Type::Error = &**self { + return Some((self.clone(), &[])); + } + let typ = if params.len() == args.len() { Cow::Borrowed(self) } else { diff --git a/check/src/typecheck.rs b/check/src/typecheck.rs index 4b2c511189..4b262ae251 100644 --- a/check/src/typecheck.rs +++ b/check/src/typecheck.rs @@ -1656,7 +1656,7 @@ impl<'a> Typecheck<'a> { ); // We still define the type so that any uses later on in the program // won't error on UndefinedType - let hole = self.subs.hole(); + let hole = self.subs.error(); alias = self.new_alias(name.clone(), Vec::new(), hole); &alias } diff --git a/check/tests/fail.rs b/check/tests/fail.rs index 306a4fd3e4..a41aaebeb7 100644 --- a/check/tests/fail.rs +++ b/check/tests/fail.rs @@ -801,3 +801,38 @@ match reverse (Cons 1 Nil) with "#, Unification(..) } + +test_check_err! { + missing_type_field, + r#" +type Alternative f = { + empty : forall a . f a, +} + +rec +type Arr r a b = a -> Eff r b + +type Eff r a = + | Pure a + | Impure : forall x . r x -> Arr r x a -> Eff r a +in + +let any x = any x + +let { HttpEffect } = () + +let alt = + type Alt r a = + | Empty + .. r + let alternative : Alternative (Eff [| alt : Alt | r |]) = { + empty = any (), + } + { alternative } + +let alternative : Alternative (Eff (HttpEffect r)) = alt.alternative + +() +"#, +UndefinedField(..) +}