iter 22b.2.1: add Constraint struct, Type::Forall.constraints
This commit is contained in:
@@ -1845,7 +1845,7 @@ impl<'a> Emitter<'a> {
|
||||
))
|
||||
})?;
|
||||
let (forall_vars, params, ret) = match &fdef.ty {
|
||||
Type::Forall { vars, body } => match body.as_ref() {
|
||||
Type::Forall { vars, constraints: _, body } => match body.as_ref() {
|
||||
Type::Fn { params, ret, .. } => {
|
||||
(vars.clone(), params.clone(), (**ret).clone())
|
||||
}
|
||||
@@ -2434,7 +2434,7 @@ impl<'a> Emitter<'a> {
|
||||
let cty = self.synth_with_extras(callee, extras)?;
|
||||
match cty {
|
||||
Type::Fn { ret, .. } => Ok(*ret),
|
||||
Type::Forall { vars, body } => {
|
||||
Type::Forall { vars, constraints: _, body } => {
|
||||
let arg_tys: Vec<Type> = args
|
||||
.iter()
|
||||
.map(|a| self.synth_with_extras(a, extras))
|
||||
|
||||
@@ -191,8 +191,9 @@ pub(crate) fn qualify_local_types_codegen(
|
||||
param_modes: vec![],
|
||||
ret_mode: ParamMode::Implicit,
|
||||
},
|
||||
Type::Forall { vars, body } => Type::Forall {
|
||||
Type::Forall { vars, constraints, body } => Type::Forall {
|
||||
vars: vars.clone(),
|
||||
constraints: constraints.clone(),
|
||||
body: Box::new(qualify_local_types_codegen(body, owner_module, owner_local_types)),
|
||||
},
|
||||
Type::Var { .. } => t.clone(),
|
||||
@@ -216,7 +217,7 @@ pub(crate) fn apply_subst_to_type(t: &Type, subst: &BTreeMap<String, Type>) -> T
|
||||
param_modes: vec![],
|
||||
ret_mode: ParamMode::Implicit,
|
||||
},
|
||||
Type::Forall { vars, body } => {
|
||||
Type::Forall { vars, constraints, body } => {
|
||||
// Inner forall shadows: don't substitute re-bound names.
|
||||
let inner: BTreeMap<String, Type> = subst
|
||||
.iter()
|
||||
@@ -225,6 +226,7 @@ pub(crate) fn apply_subst_to_type(t: &Type, subst: &BTreeMap<String, Type>) -> T
|
||||
.collect();
|
||||
Type::Forall {
|
||||
vars: vars.clone(),
|
||||
constraints: constraints.clone(),
|
||||
body: Box::new(apply_subst_to_type(body, &inner)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ pub(crate) fn builtin_ail_type(name: &str) -> Option<Type> {
|
||||
// constant i1 1) on those resolved types.
|
||||
"==" => Type::Forall {
|
||||
vars: vec!["a".into()],
|
||||
constraints: vec![],
|
||||
body: Box::new(Type::Fn {
|
||||
params: vec![
|
||||
Type::Var { name: "a".into() },
|
||||
@@ -105,6 +106,7 @@ pub(crate) fn builtin_ail_type(name: &str) -> Option<Type> {
|
||||
// (`forall a. a`). Mirrors the typechecker's `builtins::install`.
|
||||
"__unreachable__" => Type::Forall {
|
||||
vars: vec!["a".into()],
|
||||
constraints: vec![],
|
||||
body: Box::new(Type::Var { name: "a".into() }),
|
||||
},
|
||||
_ => return None,
|
||||
|
||||
Reference in New Issue
Block a user