This commit is contained in:
Folkert 2022-03-11 19:41:30 +01:00
parent 30e7d94c95
commit d4da4fed88
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 27 additions and 21 deletions

View file

@ -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};

View file

@ -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))

View file

@ -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