diff --git a/compiler/can/src/module.rs b/compiler/can/src/module.rs index 2257e24b52..fa3cfee161 100644 --- a/compiler/can/src/module.rs +++ b/compiler/can/src/module.rs @@ -256,8 +256,6 @@ pub fn canonicalize_module_defs<'a>( fix_values_captured_in_closure_defs(defs, &mut MutSet::default()) } InvalidCycle(_, _) | Builtin(_) => {} - - _ => todo!(), } } @@ -297,11 +295,45 @@ fn fix_values_captured_in_closure_defs( } fn fix_values_captured_in_closure_pattern( - expr: &mut crate::pattern::Pattern, + pattern: &mut crate::pattern::Pattern, no_capture_symbols: &mut MutSet, ) { - // TODO - return (); + use crate::pattern::Pattern::*; + + match pattern { + AppliedTag { + arguments: loc_args, + .. + } => { + for (_, loc_arg) in loc_args.iter_mut() { + fix_values_captured_in_closure_pattern(&mut loc_arg.value, no_capture_symbols); + } + } + RecordDestructure { destructs, .. } => { + for loc_destruct in destructs.iter_mut() { + use crate::pattern::DestructType::*; + match &mut loc_destruct.value.typ { + Required => {} + Optional(_, loc_expr) => { + fix_values_captured_in_closure_expr(&mut loc_expr.value, no_capture_symbols) + } + Guard(_, loc_pattern) => fix_values_captured_in_closure_pattern( + &mut loc_pattern.value, + no_capture_symbols, + ), + } + } + } + Identifier(_) + | NumLiteral(_, _) + | IntLiteral(_) + | FloatLiteral(_) + | StrLiteral(_) + | Underscore + | Shadowed(_, _) + | MalformedPattern(_, _) + | UnsupportedPattern(_) => (), + } } fn fix_values_captured_in_closure_expr( diff --git a/compiler/constrain/src/uniq.rs b/compiler/constrain/src/uniq.rs index 0383f813bf..6d5faa2bb1 100644 --- a/compiler/constrain/src/uniq.rs +++ b/compiler/constrain/src/uniq.rs @@ -733,7 +733,6 @@ pub fn constrain_expr( let ret_type = Type::Variable(ret_var); let closure_var = *closure_var; let closure_ext_var = *closure_ext_var; - let closure_type = Type::Variable(closure_var); vars.push(ret_var); vars.push(closure_var); diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index c69f20e330..0e875b48d5 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -1935,7 +1935,7 @@ fn run_solve<'a>( .. } = module; - let (mut solved_subs, solved_env, problems) = + let (solved_subs, solved_env, problems) = roc_solve::module::run_solve(aliases, rigid_variables, constraint, var_store); /* diff --git a/compiler/mono/src/lib.rs b/compiler/mono/src/lib.rs index e4876e4547..e44b3d7fae 100644 --- a/compiler/mono/src/lib.rs +++ b/compiler/mono/src/lib.rs @@ -12,7 +12,6 @@ #![allow(clippy::large_enum_variant)] pub mod borrow; -pub mod closures; pub mod inc_dec; pub mod ir; pub mod layout; diff --git a/compiler/mono/tests/test_mono.rs b/compiler/mono/tests/test_mono.rs index 65ad92eabd..20843b7355 100644 --- a/compiler/mono/tests/test_mono.rs +++ b/compiler/mono/tests/test_mono.rs @@ -112,8 +112,8 @@ mod test_mono { let expected_lines = expected.split("\n").collect::>(); let result_lines = result.split("\n").collect::>(); - assert_eq!(expected_lines, result_lines); - //assert_eq!(0, 1); + // assert_eq!(expected_lines, result_lines); + assert_eq!(0, 1); } } @@ -2103,23 +2103,25 @@ mod test_mono { ), indoc!( r#" - procedure Test.1 (Test.7): - let Test.3 = 42i64; - let Test.14 = FunctionPointer Test.4; - let Test.15 = Struct {Test.3}; - let Test.4 = Struct {Test.14, Test.15}; - ret Test.4; - - procedure Test.4 (Test.11, #Attr.12): - let Test.3 = Index 0 #Attr.12; + procedure Test.1 (Test.5): + let Test.2 = 42i64; + let Test.14 = FunctionPointer Test.3; + let Test.15 = Struct {Test.2}; + let Test.3 = Struct {Test.14, Test.15}; ret Test.3; + procedure Test.3 (Test.11, #Attr.12): + let Test.2 = Index 0 #Attr.12; + ret Test.2; + procedure Test.0 (): let Test.10 = Struct {}; - let Test.6 = CallByName Test.1 Test.10; - let Test.9 = Struct {}; - let Test.8 = CallByPointer Test.6 Test.9; - ret Test.8; + let Test.4 = CallByName Test.1 Test.10; + let Test.7 = Struct {}; + let Test.8 = Index 1 Test.4; + let Test.9 = Index 0 Test.4; + let Test.6 = CallByPointer Test.9 Test.7 Test.8; + ret Test.6; "# ), )