mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +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 mut captured_symbols: Vec<(Symbol, Variable)> = Vec::new();
|
||||||
|
|
||||||
let crate::annotation::Annotation {
|
let crate::annotation::Annotation {
|
||||||
mut introduced_variables,
|
introduced_variables,
|
||||||
typ,
|
typ,
|
||||||
aliases,
|
aliases,
|
||||||
..
|
..
|
||||||
} = annotation;
|
} = annotation;
|
||||||
|
|
||||||
let def_body = {
|
let def_body = {
|
||||||
match typ.shallow_dealias() {
|
match typ.shallow_structural_dealias() {
|
||||||
Type::Function(args, _, _) => {
|
Type::Function(args, _, _) => {
|
||||||
for i in 0..args.len() {
|
for i in 0..args.len() {
|
||||||
let name = format!("closure_arg_{}_{}", ident, i);
|
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) =
|
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 {
|
let body = Expr::OpaqueRef {
|
||||||
opaque_var: var_store.fresh(),
|
opaque_var: var_store.fresh(),
|
||||||
name: effect_symbol,
|
name: effect_symbol,
|
||||||
|
@ -1528,7 +1528,7 @@ pub fn build_host_exposed_def(
|
||||||
});
|
});
|
||||||
|
|
||||||
let (specialized_def_type, type_arguments, lambda_set_variables) =
|
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 {
|
Expr::OpaqueRef {
|
||||||
opaque_var: var_store.fresh(),
|
opaque_var: var_store.fresh(),
|
||||||
name: effect_symbol,
|
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();
|
let closure_var = var_store.fresh();
|
||||||
|
|
||||||
Type::Function(
|
Type::Function(
|
||||||
|
|
|
@ -119,11 +119,8 @@ impl GeneratedInfo {
|
||||||
{
|
{
|
||||||
let a_var = var_store.fresh();
|
let a_var = var_store.fresh();
|
||||||
|
|
||||||
let actual = crate::effect_module::build_effect_actual(
|
let actual =
|
||||||
effect_symbol,
|
crate::effect_module::build_effect_actual(Type::Variable(a_var), var_store);
|
||||||
Type::Variable(a_var),
|
|
||||||
var_store,
|
|
||||||
);
|
|
||||||
|
|
||||||
scope.add_alias(
|
scope.add_alias(
|
||||||
effect_symbol,
|
effect_symbol,
|
||||||
|
|
|
@ -1064,6 +1064,19 @@ impl Type {
|
||||||
result
|
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(
|
pub fn instantiate_aliases(
|
||||||
&mut self,
|
&mut self,
|
||||||
region: Region,
|
region: Region,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue