mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Fix codegen of effect symbols
This commit is contained in:
parent
cc507f3abd
commit
caf65ba2f8
3 changed files with 20 additions and 10 deletions
|
@ -1394,14 +1394,14 @@ pub fn build_host_exposed_def(
|
|||
let mut captured_symbols: Vec<(Symbol, Variable)> = Vec::new();
|
||||
|
||||
let crate::annotation::Annotation {
|
||||
mut introduced_variables,
|
||||
introduced_variables,
|
||||
typ,
|
||||
aliases,
|
||||
..
|
||||
} = annotation;
|
||||
|
||||
let def_body = {
|
||||
match typ.shallow_dealias() {
|
||||
match typ.shallow_structural_dealias() {
|
||||
Type::Function(args, _, _) => {
|
||||
for i in 0..args.len() {
|
||||
let name = format!("closure_arg_{}_{}", ident, i);
|
||||
|
@ -1463,7 +1463,7 @@ pub fn build_host_exposed_def(
|
|||
});
|
||||
|
||||
let (specialized_def_type, type_arguments, lambda_set_variables) =
|
||||
build_fresh_opaque_variables(var_store, &mut introduced_variables);
|
||||
build_fresh_opaque_variables(var_store);
|
||||
let body = Expr::OpaqueRef {
|
||||
opaque_var: var_store.fresh(),
|
||||
name: effect_symbol,
|
||||
|
@ -1528,7 +1528,7 @@ pub fn build_host_exposed_def(
|
|||
});
|
||||
|
||||
let (specialized_def_type, type_arguments, lambda_set_variables) =
|
||||
build_fresh_opaque_variables(var_store, &mut introduced_variables);
|
||||
build_fresh_opaque_variables(var_store);
|
||||
Expr::OpaqueRef {
|
||||
opaque_var: var_store.fresh(),
|
||||
name: effect_symbol,
|
||||
|
@ -1557,7 +1557,7 @@ pub fn build_host_exposed_def(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn build_effect_actual(effect_symbol: Symbol, a_type: Type, var_store: &mut VarStore) -> Type {
|
||||
pub fn build_effect_actual(a_type: Type, var_store: &mut VarStore) -> Type {
|
||||
let closure_var = var_store.fresh();
|
||||
|
||||
Type::Function(
|
||||
|
|
|
@ -119,11 +119,8 @@ impl GeneratedInfo {
|
|||
{
|
||||
let a_var = var_store.fresh();
|
||||
|
||||
let actual = crate::effect_module::build_effect_actual(
|
||||
effect_symbol,
|
||||
Type::Variable(a_var),
|
||||
var_store,
|
||||
);
|
||||
let actual =
|
||||
crate::effect_module::build_effect_actual(Type::Variable(a_var), var_store);
|
||||
|
||||
scope.add_alias(
|
||||
effect_symbol,
|
||||
|
|
|
@ -1064,6 +1064,19 @@ impl Type {
|
|||
result
|
||||
}
|
||||
|
||||
pub fn shallow_structural_dealias(&self) -> &Self {
|
||||
let mut result = self;
|
||||
while let Type::Alias {
|
||||
actual,
|
||||
kind: AliasKind::Structural,
|
||||
..
|
||||
} = result
|
||||
{
|
||||
result = actual;
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
pub fn instantiate_aliases(
|
||||
&mut self,
|
||||
region: Region,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue