mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
make extension check work again
This commit is contained in:
parent
de37897df4
commit
b38ff78422
1 changed files with 24 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue