mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
remove closes_over
field
This commit is contained in:
parent
6c79048f9b
commit
9cecfe3558
2 changed files with 5 additions and 15 deletions
|
@ -1005,6 +1005,7 @@ mod gen_primitives {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[ignore]
|
||||||
fn io_poc_desugared() {
|
fn io_poc_desugared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
|
@ -51,7 +51,6 @@ pub struct Proc<'a> {
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
pub args: &'a [(Layout<'a>, Symbol)],
|
pub args: &'a [(Layout<'a>, Symbol)],
|
||||||
pub body: Stmt<'a>,
|
pub body: Stmt<'a>,
|
||||||
pub closes_over: Layout<'a>,
|
|
||||||
pub ret_layout: Layout<'a>,
|
pub ret_layout: Layout<'a>,
|
||||||
pub is_self_recursive: SelfRecursive,
|
pub is_self_recursive: SelfRecursive,
|
||||||
}
|
}
|
||||||
|
@ -1434,7 +1433,7 @@ fn specialize_external<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (proc_args, closes_over, ret_layout) =
|
let (proc_args, ret_layout) =
|
||||||
build_specialized_proc_from_var(env, layout_cache, pattern_symbols, fn_var)?;
|
build_specialized_proc_from_var(env, layout_cache, pattern_symbols, fn_var)?;
|
||||||
|
|
||||||
// reset subs, so we don't get type errors when specializing for a different signature
|
// reset subs, so we don't get type errors when specializing for a different signature
|
||||||
|
@ -1451,7 +1450,6 @@ fn specialize_external<'a>(
|
||||||
name: proc_name,
|
name: proc_name,
|
||||||
args: proc_args,
|
args: proc_args,
|
||||||
body: specialized_body,
|
body: specialized_body,
|
||||||
closes_over,
|
|
||||||
ret_layout,
|
ret_layout,
|
||||||
is_self_recursive: recursivity,
|
is_self_recursive: recursivity,
|
||||||
};
|
};
|
||||||
|
@ -1465,7 +1463,7 @@ fn build_specialized_proc_from_var<'a>(
|
||||||
layout_cache: &mut LayoutCache<'a>,
|
layout_cache: &mut LayoutCache<'a>,
|
||||||
pattern_symbols: &[Symbol],
|
pattern_symbols: &[Symbol],
|
||||||
fn_var: Variable,
|
fn_var: Variable,
|
||||||
) -> Result<(&'a [(Layout<'a>, Symbol)], Layout<'a>, Layout<'a>), LayoutProblem> {
|
) -> Result<(&'a [(Layout<'a>, Symbol)], Layout<'a>), LayoutProblem> {
|
||||||
match env.subs.get_without_compacting(fn_var).content {
|
match env.subs.get_without_compacting(fn_var).content {
|
||||||
Content::Structure(FlatType::Func(pattern_vars, closure_var, ret_var)) => {
|
Content::Structure(FlatType::Func(pattern_vars, closure_var, ret_var)) => {
|
||||||
build_specialized_proc(
|
build_specialized_proc(
|
||||||
|
@ -1500,7 +1498,7 @@ fn build_specialized_proc<'a>(
|
||||||
pattern_vars: &[Variable],
|
pattern_vars: &[Variable],
|
||||||
closure_var: Option<Variable>,
|
closure_var: Option<Variable>,
|
||||||
ret_var: Variable,
|
ret_var: Variable,
|
||||||
) -> Result<(&'a [(Layout<'a>, Symbol)], Layout<'a>, Layout<'a>), LayoutProblem> {
|
) -> Result<(&'a [(Layout<'a>, Symbol)], Layout<'a>), LayoutProblem> {
|
||||||
let mut proc_args = Vec::with_capacity_in(pattern_vars.len(), &env.arena);
|
let mut proc_args = Vec::with_capacity_in(pattern_vars.len(), &env.arena);
|
||||||
|
|
||||||
for (arg_var, arg_name) in pattern_vars.iter().zip(pattern_symbols.iter()) {
|
for (arg_var, arg_name) in pattern_vars.iter().zip(pattern_symbols.iter()) {
|
||||||
|
@ -1530,20 +1528,11 @@ fn build_specialized_proc<'a>(
|
||||||
|
|
||||||
let proc_args = proc_args.into_bump_slice();
|
let proc_args = proc_args.into_bump_slice();
|
||||||
|
|
||||||
let closes_over = match closure_var {
|
|
||||||
Some(cvar) => match layout_cache.from_var(&env.arena, cvar, env.subs) {
|
|
||||||
Ok(layout) => layout,
|
|
||||||
Err(LayoutProblem::UnresolvedTypeVar) => Layout::Struct(&[]),
|
|
||||||
Err(err) => panic!("TODO handle invalid function {:?}", err),
|
|
||||||
},
|
|
||||||
None => Layout::Struct(&[]),
|
|
||||||
};
|
|
||||||
|
|
||||||
let ret_layout = layout_cache
|
let ret_layout = layout_cache
|
||||||
.from_var(&env.arena, ret_var, env.subs)
|
.from_var(&env.arena, ret_var, env.subs)
|
||||||
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
||||||
|
|
||||||
Ok((proc_args, closes_over, ret_layout))
|
Ok((proc_args, ret_layout))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn specialize<'a>(
|
fn specialize<'a>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue