mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Fix importing of module params vars
This commit is contained in:
parent
89fc1104f0
commit
d23a8dc618
5 changed files with 36 additions and 61 deletions
|
@ -346,21 +346,6 @@ fn start_phase<'a>(
|
|||
None
|
||||
};
|
||||
|
||||
let mut module_params_vars = Vec::with_capacity(available_modules.len());
|
||||
|
||||
for (module_id, _) in available_modules.iter() {
|
||||
if let Some((_, _, pat)) = state.module_cache.param_patterns.get(module_id) {
|
||||
match pat.value {
|
||||
roc_can::pattern::Pattern::RecordDestructure { whole_var, .. } => {
|
||||
module_params_vars.push((*module_id, whole_var));
|
||||
}
|
||||
_ => {
|
||||
internal_error!("Module params can only be records");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BuildTask::solve_module(
|
||||
module,
|
||||
ident_ids,
|
||||
|
@ -372,7 +357,6 @@ fn start_phase<'a>(
|
|||
pending_derives,
|
||||
var_store,
|
||||
available_modules,
|
||||
module_params_vars,
|
||||
&state.exposed_types,
|
||||
dep_idents,
|
||||
declarations,
|
||||
|
@ -928,7 +912,6 @@ enum BuildTask<'a> {
|
|||
dep_idents: IdentIdsByModule,
|
||||
cached_subs: CachedTypeState,
|
||||
derived_module: SharedDerivedModule,
|
||||
module_params_vars: Vec<(ModuleId, Variable)>,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate: Option<roc_checkmate::Collector>,
|
||||
|
@ -4325,7 +4308,6 @@ impl<'a> BuildTask<'a> {
|
|||
pending_derives: PendingDerives,
|
||||
var_store: VarStore,
|
||||
imported_modules: MutMap<ModuleId, Region>,
|
||||
module_params_vars: Vec<(ModuleId, Variable)>,
|
||||
exposed_types: &ExposedByModule,
|
||||
dep_idents: IdentIdsByModule,
|
||||
declarations: Declarations,
|
||||
|
@ -4354,7 +4336,6 @@ impl<'a> BuildTask<'a> {
|
|||
module_timing,
|
||||
cached_subs,
|
||||
derived_module,
|
||||
module_params_vars,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -4410,7 +4391,7 @@ pub fn add_imports(
|
|||
def_types: &mut Vec<(Symbol, Loc<TypeOrVar>)>,
|
||||
imported_rigid_vars: &mut Vec<Variable>,
|
||||
imported_flex_vars: &mut Vec<Variable>,
|
||||
) -> (Vec<Variable>, AbilitiesStore) {
|
||||
) -> (Vec<Variable>, VecMap<ModuleId, Variable>, AbilitiesStore) {
|
||||
let mut import_variables = Vec::new();
|
||||
|
||||
let mut cached_symbol_vars = VecMap::default();
|
||||
|
@ -4517,7 +4498,31 @@ pub fn add_imports(
|
|||
},
|
||||
);
|
||||
|
||||
(import_variables, abilities_store)
|
||||
let mut imported_param_vars = VecMap::default();
|
||||
|
||||
for (module_id, _) in exposed_for_module.exposed_by_module.iter_all() {
|
||||
let ExposedModuleTypes {
|
||||
exposed_types_storage_subs: exposed_types,
|
||||
..
|
||||
} = exposed_for_module.exposed_by_module.get(module_id).unwrap();
|
||||
|
||||
if let Some(stored_aprams_var) = exposed_types.stored_params_var {
|
||||
let copied_import = exposed_types
|
||||
.storage_subs
|
||||
.export_variable_to(subs, stored_aprams_var);
|
||||
|
||||
let copied_import_var = extend_imports_data_with_copied_import(
|
||||
copied_import,
|
||||
&mut import_variables,
|
||||
imported_rigid_vars,
|
||||
imported_flex_vars,
|
||||
);
|
||||
|
||||
imported_param_vars.insert(*module_id, copied_import_var);
|
||||
}
|
||||
}
|
||||
|
||||
(import_variables, imported_param_vars, abilities_store)
|
||||
}
|
||||
|
||||
enum OnSymbolNotFound {
|
||||
|
@ -4623,7 +4628,6 @@ struct SolveResult {
|
|||
#[allow(clippy::complexity)]
|
||||
fn run_solve_solve(
|
||||
exposed_for_module: ExposedForModule,
|
||||
original_param_vars: Vec<(ModuleId, Variable)>,
|
||||
mut types: Types,
|
||||
mut constraints: Constraints,
|
||||
constraint: ConstraintSoa,
|
||||
|
@ -4650,7 +4654,7 @@ fn run_solve_solve(
|
|||
|
||||
let mut subs = Subs::new_from_varstore(var_store);
|
||||
|
||||
let (mut import_variables, abilities_store) = add_imports(
|
||||
let (import_variables, imported_param_vars, abilities_store) = add_imports(
|
||||
module.module_id,
|
||||
&mut constraints,
|
||||
&mut subs,
|
||||
|
@ -4661,28 +4665,6 @@ fn run_solve_solve(
|
|||
&mut imported_flex_vars,
|
||||
);
|
||||
|
||||
let mut imported_param_vars = HashMap::with_capacity(original_param_vars.len());
|
||||
|
||||
for (module_id, params_var) in original_param_vars.iter() {
|
||||
let ExposedModuleTypes {
|
||||
exposed_types_storage_subs: exposed_types,
|
||||
resolved_implementations: _,
|
||||
} = exposed_for_module.exposed_by_module.get(module_id).unwrap();
|
||||
|
||||
let copied_import = exposed_types
|
||||
.storage_subs
|
||||
.export_variable_to(&mut subs, *params_var);
|
||||
|
||||
let copied_import_var = extend_imports_data_with_copied_import(
|
||||
copied_import,
|
||||
&mut import_variables,
|
||||
&mut imported_rigid_vars,
|
||||
&mut imported_flex_vars,
|
||||
);
|
||||
|
||||
imported_param_vars.insert(*module_id, copied_import_var);
|
||||
}
|
||||
|
||||
let actual_constraint = constraints.let_import_constraint(
|
||||
imported_rigid_vars,
|
||||
imported_flex_vars,
|
||||
|
@ -4776,7 +4758,6 @@ fn run_solve<'a>(
|
|||
ident_ids: IdentIds,
|
||||
mut module_timing: ModuleTiming,
|
||||
exposed_for_module: ExposedForModule,
|
||||
module_params_vars: Vec<(ModuleId, Variable)>,
|
||||
types: Types,
|
||||
constraints: Constraints,
|
||||
constraint: ConstraintSoa,
|
||||
|
@ -4812,7 +4793,6 @@ fn run_solve<'a>(
|
|||
match cached_types.lock().remove(&module_id) {
|
||||
None => run_solve_solve(
|
||||
exposed_for_module,
|
||||
module_params_vars,
|
||||
types,
|
||||
constraints,
|
||||
constraint,
|
||||
|
@ -4844,7 +4824,6 @@ fn run_solve<'a>(
|
|||
} else {
|
||||
run_solve_solve(
|
||||
exposed_for_module,
|
||||
module_params_vars,
|
||||
types,
|
||||
constraints,
|
||||
constraint,
|
||||
|
@ -6265,7 +6244,6 @@ fn run_task<'a>(
|
|||
dep_idents,
|
||||
cached_subs,
|
||||
derived_module,
|
||||
module_params_vars,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -6274,7 +6252,6 @@ fn run_task<'a>(
|
|||
ident_ids,
|
||||
module_timing,
|
||||
exposed_for_module,
|
||||
module_params_vars,
|
||||
types,
|
||||
constraints,
|
||||
constraint,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue