make extension check work again

This commit is contained in:
Folkert 2022-03-16 22:19:48 +01:00
parent de37897df4
commit b38ff78422
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -706,7 +706,7 @@ fn can_extension_type<'a>(
local_aliases,
references,
);
if valid_extension_type(ext_type.shallow_dealias()) {
if valid_extension_type(shallow_dealias_with_scope(scope, &ext_type)) {
ext_type
} else {
// Report an error but mark the extension variable to be inferred
@ -730,6 +730,29 @@ fn can_extension_type<'a>(
}
}
/// a shallow dealias, continue until the first constructor is not an alias.
fn shallow_dealias_with_scope<'a>(scope: &'a mut Scope, typ: &'a Type) -> &'a Type {
let mut result = typ;
loop {
match result {
Type::Alias { actual, .. } => {
// another loop
result = actual;
}
Type::DelayedAlias(AliasCommon { symbol, .. }) => match scope.lookup_alias(*symbol) {
None => unreachable!(),
Some(alias) => {
result = &alias.typ;
}
},
_ => break,
}
}
result
}
pub fn instantiate_and_freshen_alias_type(
var_store: &mut VarStore,
introduced_variables: &mut IntroducedVariables,