mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
cleanup
This commit is contained in:
parent
30e7d94c95
commit
d4da4fed88
3 changed files with 27 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
||||||
use roc_builtins::std::StdLib;
|
use roc_builtins::std::StdLib;
|
||||||
use roc_can::constraint::{Constraint, Constraints};
|
use roc_can::constraint::{Constraint, Constraints};
|
||||||
use roc_can::def::Declaration;
|
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_module::symbol::{ModuleId, Symbol};
|
||||||
use roc_region::all::{Loc, Region};
|
use roc_region::all::{Loc, Region};
|
||||||
use roc_types::solved_types::{FreeVars, SolvedType};
|
use roc_types::solved_types::{FreeVars, SolvedType};
|
||||||
|
|
|
@ -3133,16 +3133,13 @@ fn run_solve<'a>(
|
||||||
|
|
||||||
if NEW_TYPES {
|
if NEW_TYPES {
|
||||||
for mut import in imported_storage_subs {
|
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
|
let copied_import = import
|
||||||
.storage_subs
|
.storage_subs
|
||||||
.export_variable_to(&mut subs, import.variable);
|
.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
|
// not a typo; rigids are turned into flex during type inference, but when imported we must
|
||||||
// consider them rigid variables
|
// consider them rigid variables
|
||||||
|
rigid_vars.extend(copied_import.rigid);
|
||||||
rigid_vars.extend(copied_import.flex);
|
rigid_vars.extend(copied_import.flex);
|
||||||
|
|
||||||
import_variables.extend(copied_import.registered);
|
import_variables.extend(copied_import.registered);
|
||||||
|
@ -3160,8 +3157,6 @@ fn run_solve<'a>(
|
||||||
let (solved_subs, solved_env, problems) =
|
let (solved_subs, solved_env, problems) =
|
||||||
roc_solve::module::run_solve(&constraints, actual_constraint, rigid_variables, subs);
|
roc_solve::module::run_solve(&constraints, actual_constraint, rigid_variables, subs);
|
||||||
|
|
||||||
dbg!(&solved_subs, &solved_env);
|
|
||||||
|
|
||||||
let exposed_vars_by_symbol: Vec<_> = solved_env
|
let exposed_vars_by_symbol: Vec<_> = solved_env
|
||||||
.vars_by_symbol()
|
.vars_by_symbol()
|
||||||
.filter(|(k, _)| exposed_symbols.contains(k))
|
.filter(|(k, _)| exposed_symbols.contains(k))
|
||||||
|
|
|
@ -3303,7 +3303,7 @@ fn restore_help(subs: &mut Subs, initial: Variable) {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct StorageSubs {
|
pub struct StorageSubs {
|
||||||
pub subs: Subs,
|
subs: Subs,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -3821,7 +3821,17 @@ fn deep_copy_var_to_help<'a>(
|
||||||
copy
|
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 {
|
RecursionVar {
|
||||||
opt_name,
|
opt_name,
|
||||||
|
@ -3902,7 +3912,6 @@ pub struct CopiedImport {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CopyImportEnv<'a> {
|
struct CopyImportEnv<'a> {
|
||||||
arena: &'a bumpalo::Bump,
|
|
||||||
visited: bumpalo::collections::Vec<'a, Variable>,
|
visited: bumpalo::collections::Vec<'a, Variable>,
|
||||||
source: &'a mut Subs,
|
source: &'a mut Subs,
|
||||||
target: &'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 visited = bumpalo::collections::Vec::with_capacity_in(256, &arena);
|
||||||
|
|
||||||
let mut env = CopyImportEnv {
|
let mut env = CopyImportEnv {
|
||||||
arena: &arena,
|
|
||||||
visited,
|
visited,
|
||||||
source,
|
source,
|
||||||
target,
|
target,
|
||||||
|
@ -3943,7 +3951,6 @@ pub fn copy_import_to(
|
||||||
flex,
|
flex,
|
||||||
rigid,
|
rigid,
|
||||||
registered,
|
registered,
|
||||||
arena: _,
|
|
||||||
target: _,
|
target: _,
|
||||||
} = env;
|
} = env;
|
||||||
|
|
||||||
|
@ -4200,28 +4207,32 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexVar(_) => {
|
FlexVar(_opt_name_index) => {
|
||||||
// copy the name?
|
// 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);
|
env.flex.push(copy);
|
||||||
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
Error => {
|
Error => {
|
||||||
todo!()
|
// elm says in `variableToCanType` that this basically should not happen
|
||||||
|
unreachable!("This should not happen (based on my reading of elm compiler source")
|
||||||
// copy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidVar(name_index) => {
|
RigidVar(name_index) => {
|
||||||
let name = env.source.field_names[name_index.index as usize].clone();
|
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 new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||||
|
|
||||||
let mut desc = make_descriptor(RigidVar(new_name_index));
|
env.target
|
||||||
desc.rank = max_rank;
|
.set(copy, make_descriptor(RigidVar(new_name_index)));
|
||||||
env.target.set(copy, desc);
|
|
||||||
|
|
||||||
println!("look a rigid -------------------------> in copy_import");
|
|
||||||
env.rigid.push(copy);
|
env.rigid.push(copy);
|
||||||
|
|
||||||
copy
|
copy
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue