diff --git a/compiler/constrain/src/module.rs b/compiler/constrain/src/module.rs index 6ffc2a5af5..a5e94f591e 100644 --- a/compiler/constrain/src/module.rs +++ b/compiler/constrain/src/module.rs @@ -1,7 +1,7 @@ use roc_builtins::std::StdLib; use roc_can::constraint::{Constraint, Constraints}; use roc_can::def::Declaration; -use roc_collections::all::{MutMap, MutSet, SendMap}; +use roc_collections::all::{MutMap, MutSet}; use roc_module::symbol::{ModuleId, Symbol}; use roc_region::all::{Loc, Region}; use roc_types::solved_types::{FreeVars, SolvedType}; diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index e57b152f79..fee4793e13 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -3133,16 +3133,13 @@ fn run_solve<'a>( if NEW_TYPES { for mut import in imported_storage_subs { - // if format!("{:?}", import.loc_symbol.value).contains("after") { - // dbg!(&import.storage_subs, import.variable, import.loc_symbol); - // } let copied_import = import .storage_subs .export_variable_to(&mut subs, import.variable); - rigid_vars.extend(copied_import.rigid); // not a typo; rigids are turned into flex during type inference, but when imported we must // consider them rigid variables + rigid_vars.extend(copied_import.rigid); rigid_vars.extend(copied_import.flex); import_variables.extend(copied_import.registered); @@ -3160,8 +3157,6 @@ fn run_solve<'a>( let (solved_subs, solved_env, problems) = roc_solve::module::run_solve(&constraints, actual_constraint, rigid_variables, subs); - dbg!(&solved_subs, &solved_env); - let exposed_vars_by_symbol: Vec<_> = solved_env .vars_by_symbol() .filter(|(k, _)| exposed_symbols.contains(k)) diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 5cc5210c65..b95b557d50 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -3303,7 +3303,7 @@ fn restore_help(subs: &mut Subs, initial: Variable) { #[derive(Clone, Debug)] pub struct StorageSubs { - pub subs: Subs, + subs: Subs, } #[derive(Copy, Clone, Debug)] @@ -3821,7 +3821,17 @@ fn deep_copy_var_to_help<'a>( copy } - FlexVar(_) | Error => copy, + FlexVar(Some(name_index)) => { + let name = source.field_names[name_index.index as usize].clone(); + let new_name_index = SubsIndex::push_new(&mut target.field_names, name); + + let content = FlexVar(Some(new_name_index)); + target.set_content(copy, content); + + copy + } + + FlexVar(None) | Error => copy, RecursionVar { opt_name, @@ -3902,7 +3912,6 @@ pub struct CopiedImport { } struct CopyImportEnv<'a> { - arena: &'a bumpalo::Bump, visited: bumpalo::collections::Vec<'a, Variable>, source: &'a mut Subs, target: &'a mut Subs, @@ -3926,7 +3935,6 @@ pub fn copy_import_to( let visited = bumpalo::collections::Vec::with_capacity_in(256, &arena); let mut env = CopyImportEnv { - arena: &arena, visited, source, target, @@ -3943,7 +3951,6 @@ pub fn copy_import_to( flex, rigid, registered, - arena: _, target: _, } = env; @@ -4200,28 +4207,32 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl copy } - FlexVar(_) => { - // copy the name? + FlexVar(_opt_name_index) => { + // if let Some(name_index) = opt_name_index { + // let name = env.source.field_names[name_index.index as usize].clone(); + // let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name); + // + // let content = FlexVar(Some(new_name_index)); + // env.target.set_content(copy, content); + // } + env.flex.push(copy); copy } Error => { - todo!() - - // copy + // elm says in `variableToCanType` that this basically should not happen + unreachable!("This should not happen (based on my reading of elm compiler source") } RigidVar(name_index) => { let name = env.source.field_names[name_index.index as usize].clone(); let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name); - let mut desc = make_descriptor(RigidVar(new_name_index)); - desc.rank = max_rank; - env.target.set(copy, desc); + env.target + .set(copy, make_descriptor(RigidVar(new_name_index))); - println!("look a rigid -------------------------> in copy_import"); env.rigid.push(copy); copy