Merge branch 'trunk' into optional-fields-in-exprs

This commit is contained in:
Richard Feldman 2020-11-03 20:59:28 -05:00 committed by GitHub
commit 3479f61820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 366 additions and 312 deletions

View file

@ -194,42 +194,40 @@ fn gen(src: &[u8], target: Triple, opt_level: OptLevel) -> Result<ReplOutput, Fa
exposed_types, exposed_types,
); );
let loaded = loaded.expect("failed to load module"); let mut loaded = loaded.expect("failed to load module");
use roc_load::file::MonomorphizedModule; use roc_load::file::MonomorphizedModule;
let MonomorphizedModule { let MonomorphizedModule {
can_problems,
type_problems,
mono_problems,
mut procedures, mut procedures,
interns, interns,
exposed_to_host, exposed_to_host,
mut subs, mut subs,
module_id: home, module_id: home,
sources,
.. ..
} = loaded; } = loaded;
let error_count = can_problems.len() + type_problems.len() + mono_problems.len(); let mut lines = Vec::new();
if error_count > 0 { for (home, (module_path, src)) in sources {
// There were problems; report them and return. let can_problems = loaded.can_problems.remove(&home).unwrap_or_default();
let src_lines: Vec<&str> = module_src.split('\n').collect(); let type_problems = loaded.type_problems.remove(&home).unwrap_or_default();
let mono_problems = loaded.mono_problems.remove(&home).unwrap_or_default();
// Used for reporting where an error came from. let error_count = can_problems.len() + type_problems.len() + mono_problems.len();
//
// TODO: maybe Reporting should have this be an Option?
let path = PathBuf::new();
// Report problems if error_count == 0 {
continue;
}
let src_lines: Vec<&str> = src.split('\n').collect();
let palette = DEFAULT_PALETTE; let palette = DEFAULT_PALETTE;
// Report parsing and canonicalization problems // Report parsing and canonicalization problems
let alloc = RocDocAllocator::new(&src_lines, home, &interns); let alloc = RocDocAllocator::new(&src_lines, home, &interns);
let mut lines = Vec::with_capacity(error_count);
for problem in can_problems.into_iter() { for problem in can_problems.into_iter() {
let report = can_problem(&alloc, path.clone(), problem); let report = can_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
@ -237,8 +235,8 @@ fn gen(src: &[u8], target: Triple, opt_level: OptLevel) -> Result<ReplOutput, Fa
lines.push(buf); lines.push(buf);
} }
for problem in type_problems.into_iter() { for problem in type_problems {
let report = type_problem(&alloc, path.clone(), problem); let report = type_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
@ -246,15 +244,17 @@ fn gen(src: &[u8], target: Triple, opt_level: OptLevel) -> Result<ReplOutput, Fa
lines.push(buf); lines.push(buf);
} }
for problem in mono_problems.into_iter() { for problem in mono_problems {
let report = mono_problem(&alloc, path.clone(), problem); let report = mono_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf); lines.push(buf);
} }
}
if !lines.is_empty() {
Ok(ReplOutput::Problems(lines)) Ok(ReplOutput::Problems(lines))
} else { } else {
let context = Context::create(); let context = Context::create();

View file

@ -14,38 +14,52 @@ use target_lexicon::Triple;
#[allow(clippy::cognitive_complexity)] #[allow(clippy::cognitive_complexity)]
pub fn gen_from_mono_module( pub fn gen_from_mono_module(
arena: &Bump, arena: &Bump,
loaded: MonomorphizedModule, mut loaded: MonomorphizedModule,
file_path: PathBuf, _file_path: PathBuf,
target: Triple, target: Triple,
app_o_file: &Path, app_o_file: &Path,
opt_level: OptLevel, opt_level: OptLevel,
) { ) {
use roc_reporting::report::{can_problem, type_problem, RocDocAllocator, DEFAULT_PALETTE}; use roc_reporting::report::{
can_problem, mono_problem, type_problem, RocDocAllocator, DEFAULT_PALETTE,
};
let src = loaded.src; for (home, (module_path, src)) in loaded.sources {
let home = loaded.module_id; let src_lines: Vec<&str> = src.split('\n').collect();
let src_lines: Vec<&str> = src.split('\n').collect(); let palette = DEFAULT_PALETTE;
let palette = DEFAULT_PALETTE;
// Report parsing and canonicalization problems // Report parsing and canonicalization problems
let alloc = RocDocAllocator::new(&src_lines, home, &loaded.interns); let alloc = RocDocAllocator::new(&src_lines, home, &loaded.interns);
for problem in loaded.can_problems.into_iter() { let problems = loaded.can_problems.remove(&home).unwrap_or_default();
let report = can_problem(&alloc, file_path.clone(), problem); for problem in problems.into_iter() {
let mut buf = String::new(); let report = can_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
println!("\n{}\n", buf); println!("\n{}\n", buf);
} }
for problem in loaded.type_problems.into_iter() { let problems = loaded.type_problems.remove(&home).unwrap_or_default();
let report = type_problem(&alloc, file_path.clone(), problem); for problem in problems {
let mut buf = String::new(); let report = type_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
println!("\n{}\n", buf); println!("\n{}\n", buf);
}
let problems = loaded.mono_problems.remove(&home).unwrap_or_default();
for problem in problems {
let report = mono_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette);
println!("\n{}\n", buf);
}
} }
// Generate the binary // Generate the binary

View file

@ -285,6 +285,7 @@ mod gen_list {
r#" r#"
Bit : [ Zero, One ] Bit : [ Zero, One ]
byte : List Bit
byte = [ Zero, One, Zero, One, Zero, Zero, One, Zero ] byte = [ Zero, One, Zero, One, Zero, Zero, One, Zero ]
initialCounts = { zeroes: 0, ones: 0 } initialCounts = { zeroes: 0, ones: 0 }
@ -313,7 +314,7 @@ mod gen_list {
empty = empty =
[] []
List.keepIf empty (\x -> True) List.keepIf empty (\_ -> True)
"# "#
), ),
RocList::from_slice(&[]), RocList::from_slice(&[]),
@ -345,7 +346,7 @@ mod gen_list {
indoc!( indoc!(
r#" r#"
alwaysTrue : Int -> Bool alwaysTrue : Int -> Bool
alwaysTrue = \i -> alwaysTrue = \_ ->
True True
oneThroughEight : List Int oneThroughEight : List Int
@ -366,7 +367,7 @@ mod gen_list {
indoc!( indoc!(
r#" r#"
alwaysFalse : Int -> Bool alwaysFalse : Int -> Bool
alwaysFalse = \i -> alwaysFalse = \_ ->
False False
List.keepIf [1,2,3,4,5,6,7,8] alwaysFalse List.keepIf [1,2,3,4,5,6,7,8] alwaysFalse

View file

@ -557,7 +557,7 @@ mod gen_num {
indoc!( indoc!(
r#" r#"
always42 : Num.Num Num.Integer -> Num.Num Num.Integer always42 : Num.Num Num.Integer -> Num.Num Num.Integer
always42 = \num -> 42 always42 = \_ -> 42
always42 5 always42 5
"# "#

View file

@ -294,7 +294,7 @@ mod gen_primitives {
r#" r#"
wrapper = \{} -> wrapper = \{} ->
alwaysFloatIdentity : Int -> (Float -> Float) alwaysFloatIdentity : Int -> (Float -> Float)
alwaysFloatIdentity = \num -> alwaysFloatIdentity = \_ ->
(\a -> a) (\a -> a)
(alwaysFloatIdentity 2) 3.14 (alwaysFloatIdentity 2) 3.14
@ -362,7 +362,7 @@ mod gen_primitives {
pi = 3.14 pi = 3.14
answer if pi > 3 then answer else answer
"# "#
), ),
42, 42,
@ -376,7 +376,7 @@ mod gen_primitives {
pi = 3.14 pi = 3.14
pi if answer > 3 then pi else pi
"# "#
), ),
3.14, 3.14,
@ -384,87 +384,89 @@ mod gen_primitives {
); );
} }
#[test] // These tests caught a bug in how Defs are converted to the mono IR
fn gen_chained_defs() { // but they have UnusedDef or UnusedArgument problems, and don't run any more
assert_evals_to!( // #[test]
indoc!( // fn gen_chained_defs() {
r#" // assert_evals_to!(
x = i1 // indoc!(
i3 = i2 // r#"
i1 = 1337 // x = i1
i2 = i1 // i3 = i2
y = 12.4 // i1 = 1337
// i2 = i1
i3 // y = 12.4
"# //
), // i3
1337, // "#
i64 // ),
); // 1337,
} // i64
// );
#[test] // }
fn gen_nested_defs_old() { //
assert_evals_to!( // #[test]
indoc!( // fn gen_nested_defs_old() {
r#" // assert_evals_to!(
x = 5 // indoc!(
// r#"
answer = // x = 5
i3 = i2 //
// answer =
nested = // i3 = i2
a = 1.0 //
b = 5 // nested =
// a = 1.0
i1 // b = 5
//
i1 = 1337 // i1
i2 = i1 //
// i1 = 1337
// i2 = i1
nested //
//
# None of this should affect anything, even though names // nested
# overlap with the previous nested defs //
unused = // # None of this should affect anything, even though names
nested = 17 // # overlap with the previous nested defs
// unused =
i1 = 84.2 // nested = 17
//
nested // i1 = 84.2
//
y = 12.4 // nested
//
answer // y = 12.4
"# //
), // answer
1337, // "#
i64 // ),
); // 1337,
} // i64
// );
#[test] // }
fn let_x_in_x() { //
assert_evals_to!( // #[test]
indoc!( // fn let_x_in_x() {
r#" // assert_evals_to!(
x = 5 // indoc!(
// r#"
answer = // x = 5
1337 //
// answer =
unused = // 1337
nested = 17 //
nested // unused =
// nested = 17
answer // nested
"# //
), // answer
1337, // "#
i64 // ),
); // 1337,
} // i64
// );
// }
#[test] #[test]
fn factorial() { fn factorial() {

View file

@ -254,11 +254,11 @@ mod gen_records {
r#" r#"
v = {} v = {}
1 v
"# "#
), ),
1, (),
i64 ()
); );
} }
#[test] #[test]

View file

@ -23,11 +23,12 @@ mod gen_tags {
x : Maybe Int x : Maybe Int
x = Nothing x = Nothing
0x1 x
"# "#
), ),
1, 1,
i64 (i64, i64),
|(tag, _)| tag
); );
} }
@ -41,11 +42,12 @@ mod gen_tags {
x : Maybe Int x : Maybe Int
x = Nothing x = Nothing
0x1 x
"# "#
), ),
1, 1,
i64 (i64, i64),
|(tag, _)| tag
); );
} }
@ -59,11 +61,11 @@ mod gen_tags {
y : Maybe Int y : Maybe Int
y = Just 0x4 y = Just 0x4
0x1 y
"# "#
), ),
1, (0, 0x4),
i64 (i64, i64)
); );
} }
@ -77,11 +79,11 @@ mod gen_tags {
y : Maybe Int y : Maybe Int
y = Just 0x4 y = Just 0x4
0x1 y
"# "#
), ),
1, (0, 0x4),
i64 (i64, i64)
); );
} }
@ -99,11 +101,11 @@ mod gen_tags {
y : Maybe Fruit y : Maybe Fruit
y = Just orange y = Just orange
0x1 y
"# "#
), ),
1, (0, 2),
i64 (i64, i64)
); );
} }
@ -350,7 +352,7 @@ mod gen_tags {
when x is when x is
These a b -> a + b These a b -> a + b
That v -> 8 That v -> v
This v -> v This v -> v
"# "#
), ),
@ -616,10 +618,10 @@ mod gen_tags {
x : [ Pair Int ] x : [ Pair Int ]
x = Pair 2 x = Pair 2
0x3 x
"# "#
), ),
3, 2,
i64 i64
); );
} }
@ -637,11 +639,11 @@ mod gen_tags {
x = Just (Just 41) x = Just (Just 41)
main = main =
5 x
"# "#
), ),
5, (0, (0, 41)),
i64 (i64, (i64, i64))
); );
} }
#[test] #[test]
@ -654,11 +656,11 @@ mod gen_tags {
v : Unit v : Unit
v = Unit v = Unit
1 v
"# "#
), ),
1, (),
i64 ()
); );
} }
@ -667,8 +669,6 @@ mod gen_tags {
assert_evals_to!( assert_evals_to!(
indoc!( indoc!(
r#" r#"
Maybe a : [ Nothing, Just a ]
x = { a : { b : 0x5 } } x = { a : { b : 0x5 } }
y = x.a y = x.a

View file

@ -50,14 +50,10 @@ pub fn helper<'a>(
exposed_types, exposed_types,
); );
let loaded = loaded.expect("failed to load module"); let mut loaded = loaded.expect("failed to load module");
use roc_load::file::MonomorphizedModule; use roc_load::file::MonomorphizedModule;
let MonomorphizedModule { let MonomorphizedModule {
module_id: home,
can_problems,
type_problems,
mono_problems,
mut procedures, mut procedures,
interns, interns,
exposed_to_host, exposed_to_host,
@ -76,47 +72,52 @@ pub fn helper<'a>(
let target = target_lexicon::Triple::host(); let target = target_lexicon::Triple::host();
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32; let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
// don't panic based on the errors here, so we can test that RuntimeError generates the correct code let mut lines = Vec::new();
let errors = can_problems // errors whose reporting we delay (so we can see that code gen generates runtime errors)
.into_iter() let mut delayed_errors = Vec::new();
.filter(|problem| {
use roc_problem::can::Problem::*;
// Ignore "unused" problems for (home, (module_path, src)) in loaded.sources {
match problem { use roc_reporting::report::{
UnusedDef(_, _) | UnusedArgument(_, _, _) | UnusedImport(_, _) => false, can_problem, mono_problem, type_problem, RocDocAllocator, DEFAULT_PALETTE,
_ => true, };
}
})
.collect::<Vec<roc_problem::can::Problem>>();
use roc_reporting::report::{ let can_problems = loaded.can_problems.remove(&home).unwrap_or_default();
can_problem, mono_problem, type_problem, RocDocAllocator, DEFAULT_PALETTE, let type_problems = loaded.type_problems.remove(&home).unwrap_or_default();
}; let mono_problems = loaded.mono_problems.remove(&home).unwrap_or_default();
let error_count = errors.len() + type_problems.len() + mono_problems.len(); let error_count = can_problems.len() + type_problems.len() + mono_problems.len();
let fatal_error_count = type_problems.len() + mono_problems.len();
if error_count > 0 { if error_count == 0 {
// There were problems; report them and return. continue;
let src_lines: Vec<&str> = module_src.split('\n').collect(); }
// Used for reporting where an error came from. let src_lines: Vec<&str> = src.split('\n').collect();
//
// TODO: maybe Reporting should have this be an Option?
let path = PathBuf::new();
// Report problems
let palette = DEFAULT_PALETTE; let palette = DEFAULT_PALETTE;
// Report parsing and canonicalization problems // Report parsing and canonicalization problems
let alloc = RocDocAllocator::new(&src_lines, home, &interns); let alloc = RocDocAllocator::new(&src_lines, home, &interns);
let mut lines = Vec::with_capacity(error_count); use roc_problem::can::Problem::*;
let can_problems = errors.clone();
for problem in can_problems.into_iter() { for problem in can_problems.into_iter() {
let report = can_problem(&alloc, path.clone(), problem); // Ignore "unused" problems
match problem {
UnusedDef(_, _) | UnusedArgument(_, _, _) | UnusedImport(_, _) => {
delayed_errors.push(problem);
continue;
}
_ => {
let report = can_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf);
}
}
}
for problem in type_problems {
let report = type_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
@ -124,31 +125,19 @@ pub fn helper<'a>(
lines.push(buf); lines.push(buf);
} }
for problem in type_problems.into_iter() { for problem in mono_problems {
let report = type_problem(&alloc, path.clone(), problem); let report = mono_problem(&alloc, module_path.clone(), problem);
let mut buf = String::new(); let mut buf = String::new();
report.render_color_terminal(&mut buf, &alloc, &palette); report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf); lines.push(buf);
} }
}
for problem in mono_problems.into_iter() { if !lines.is_empty() {
let report = mono_problem(&alloc, path.clone(), problem); println!("{}", lines.join("\n"));
let mut buf = String::new(); assert_eq!(0, 1, "Mistakes were made");
report.render_color_terminal(&mut buf, &alloc, &palette);
lines.push(buf);
}
println!("{}", (&lines).join("\n"));
// we want to continue onward only for canonical problems at the moment,
// to check that they codegen into runtime exceptions
if fatal_error_count > 0 {
assert_eq!(0, 1, "problems occured");
}
} }
let module = roc_gen::llvm::build::module_from_builtins(context, "app"); let module = roc_gen::llvm::build::module_from_builtins(context, "app");
@ -261,7 +250,7 @@ pub fn helper<'a>(
let lib = module_to_dylib(&env.module, &target, opt_level) let lib = module_to_dylib(&env.module, &target, opt_level)
.expect("Error loading compiled dylib for test"); .expect("Error loading compiled dylib for test");
(main_fn_name, errors, lib) (main_fn_name, delayed_errors, lib)
} }
// TODO this is almost all code duplication with assert_llvm_evals_to // TODO this is almost all code duplication with assert_llvm_evals_to

View file

@ -16,8 +16,7 @@ use roc_constrain::module::{constrain_module, ExposedModuleTypes, SubsByModule};
use roc_module::ident::{Ident, ModuleName}; use roc_module::ident::{Ident, ModuleName};
use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol}; use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol};
use roc_mono::ir::{ use roc_mono::ir::{
CapturedSymbols, ExternalSpecializations, MonoProblem, PartialProc, PendingSpecialization, CapturedSymbols, ExternalSpecializations, PartialProc, PendingSpecialization, Proc, Procs,
Proc, Procs,
}; };
use roc_mono::layout::{Layout, LayoutCache}; use roc_mono::layout::{Layout, LayoutCache};
use roc_parse::ast::{self, Attempting, ExposesEntry, ImportsEntry}; use roc_parse::ast::{self, Attempting, ExposesEntry, ImportsEntry};
@ -201,15 +200,24 @@ impl Dependencies {
#[derive(Debug, Default)] #[derive(Debug, Default)]
struct ModuleCache<'a> { struct ModuleCache<'a> {
module_names: MutMap<ModuleId, ModuleName>, module_names: MutMap<ModuleId, ModuleName>,
/// Phases
headers: MutMap<ModuleId, ModuleHeader<'a>>, headers: MutMap<ModuleId, ModuleHeader<'a>>,
parsed: MutMap<ModuleId, ParsedModule<'a>>, parsed: MutMap<ModuleId, ParsedModule<'a>>,
canonicalized: MutMap<ModuleId, CanonicalizedModule<'a>>, canonicalized: MutMap<ModuleId, CanonicalizedModule<'a>>,
aliases: MutMap<ModuleId, MutMap<Symbol, Alias>>, aliases: MutMap<ModuleId, MutMap<Symbol, Alias>>,
constrained: MutMap<ModuleId, ConstrainedModule<'a>>, constrained: MutMap<ModuleId, ConstrainedModule>,
typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>, typechecked: MutMap<ModuleId, TypeCheckedModule<'a>>,
found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>, found_specializations: MutMap<ModuleId, FoundSpecializationsModule<'a>>,
external_specializations_requested: MutMap<ModuleId, ExternalSpecializations>, external_specializations_requested: MutMap<ModuleId, ExternalSpecializations>,
/// Various information
documentation: MutMap<ModuleId, ModuleDocumentation>, documentation: MutMap<ModuleId, ModuleDocumentation>,
can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
mono_problems: MutMap<ModuleId, Vec<roc_mono::ir::MonoProblem>>,
sources: MutMap<ModuleId, (PathBuf, &'a str)>,
} }
fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) -> BuildTask<'a> { fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) -> BuildTask<'a> {
@ -314,7 +322,6 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
module, module,
ident_ids, ident_ids,
module_timing, module_timing,
src,
constraint, constraint,
var_store, var_store,
imported_modules, imported_modules,
@ -326,7 +333,6 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
module, module,
ident_ids, ident_ids,
module_timing, module_timing,
src,
constraint, constraint,
var_store, var_store,
imported_modules, imported_modules,
@ -344,7 +350,6 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
module_timing, module_timing,
solved_subs, solved_subs,
decls, decls,
finished_info,
ident_ids, ident_ids,
} = typechecked; } = typechecked;
@ -354,7 +359,6 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
module_timing, module_timing,
solved_subs, solved_subs,
decls, decls,
finished_info,
ident_ids, ident_ids,
exposed_to_host: state.exposed_to_host.clone(), exposed_to_host: state.exposed_to_host.clone(),
} }
@ -378,7 +382,6 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
subs, subs,
procs, procs,
layout_cache, layout_cache,
finished_info,
} = found_specializations; } = found_specializations;
BuildTask::MakeSpecializations { BuildTask::MakeSpecializations {
@ -388,7 +391,6 @@ fn start_phase<'a>(module_id: ModuleId, phase: Phase, state: &mut State<'a>) ->
procs, procs,
layout_cache, layout_cache,
specializations_we_must_make, specializations_we_must_make,
finished_info,
} }
} }
} }
@ -399,11 +401,11 @@ pub struct LoadedModule {
pub module_id: ModuleId, pub module_id: ModuleId,
pub interns: Interns, pub interns: Interns,
pub solved: Solved<Subs>, pub solved: Solved<Subs>,
pub can_problems: Vec<roc_problem::can::Problem>, pub can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
pub type_problems: Vec<solve::TypeError>, pub type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
pub declarations_by_id: MutMap<ModuleId, Vec<Declaration>>, pub declarations_by_id: MutMap<ModuleId, Vec<Declaration>>,
pub exposed_to_host: MutMap<Symbol, Variable>, pub exposed_to_host: MutMap<Symbol, Variable>,
pub src: Box<str>, pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
pub timings: MutMap<ModuleId, ModuleTiming>, pub timings: MutMap<ModuleId, ModuleTiming>,
pub documentation: MutMap<ModuleId, ModuleDocumentation>, pub documentation: MutMap<ModuleId, ModuleDocumentation>,
} }
@ -417,6 +419,7 @@ pub enum BuildProblem<'a> {
struct ModuleHeader<'a> { struct ModuleHeader<'a> {
module_id: ModuleId, module_id: ModuleId,
module_name: ModuleName, module_name: ModuleName,
module_path: PathBuf,
exposed_ident_ids: IdentIds, exposed_ident_ids: IdentIds,
deps_by_name: MutMap<ModuleName, ModuleId>, deps_by_name: MutMap<ModuleName, ModuleId>,
imported_modules: MutSet<ModuleId>, imported_modules: MutSet<ModuleId>,
@ -427,11 +430,10 @@ struct ModuleHeader<'a> {
} }
#[derive(Debug)] #[derive(Debug)]
struct ConstrainedModule<'a> { struct ConstrainedModule {
module: Module, module: Module,
declarations: Vec<Declaration>, declarations: Vec<Declaration>,
imported_modules: MutSet<ModuleId>, imported_modules: MutSet<ModuleId>,
src: &'a str,
constraint: Constraint, constraint: Constraint,
ident_ids: IdentIds, ident_ids: IdentIds,
var_store: VarStore, var_store: VarStore,
@ -446,7 +448,6 @@ pub struct TypeCheckedModule<'a> {
pub solved_subs: Solved<Subs>, pub solved_subs: Solved<Subs>,
pub decls: Vec<Declaration>, pub decls: Vec<Declaration>,
pub ident_ids: IdentIds, pub ident_ids: IdentIds,
pub finished_info: FinishedInfo<'a>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -456,7 +457,6 @@ pub struct FoundSpecializationsModule<'a> {
pub layout_cache: LayoutCache<'a>, pub layout_cache: LayoutCache<'a>,
pub procs: Procs<'a>, pub procs: Procs<'a>,
pub subs: Subs, pub subs: Subs,
pub finished_info: FinishedInfo<'a>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -464,12 +464,12 @@ pub struct MonomorphizedModule<'a> {
pub module_id: ModuleId, pub module_id: ModuleId,
pub interns: Interns, pub interns: Interns,
pub subs: Subs, pub subs: Subs,
pub can_problems: Vec<roc_problem::can::Problem>, pub can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
pub type_problems: Vec<solve::TypeError>, pub type_problems: MutMap<ModuleId, Vec<solve::TypeError>>,
pub mono_problems: Vec<roc_mono::ir::MonoProblem>, pub mono_problems: MutMap<ModuleId, Vec<roc_mono::ir::MonoProblem>>,
pub procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>, pub procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
pub exposed_to_host: MutMap<Symbol, Variable>, pub exposed_to_host: MutMap<Symbol, Variable>,
pub src: Box<str>, pub sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
pub timings: MutMap<ModuleId, ModuleTiming>, pub timings: MutMap<ModuleId, ModuleTiming>,
} }
@ -477,6 +477,7 @@ pub struct MonomorphizedModule<'a> {
struct ParsedModule<'a> { struct ParsedModule<'a> {
module_id: ModuleId, module_id: ModuleId,
module_name: ModuleName, module_name: ModuleName,
module_path: PathBuf,
src: &'a str, src: &'a str,
module_timing: ModuleTiming, module_timing: ModuleTiming,
deps_by_name: MutMap<ModuleName, ModuleId>, deps_by_name: MutMap<ModuleName, ModuleId>,
@ -498,12 +499,11 @@ enum Msg<'a> {
Header(ModuleHeader<'a>), Header(ModuleHeader<'a>),
Parsed(ParsedModule<'a>), Parsed(ParsedModule<'a>),
CanonicalizedAndConstrained { CanonicalizedAndConstrained {
constrained_module: ConstrainedModule<'a>, constrained_module: ConstrainedModule,
canonicalization_problems: Vec<roc_problem::can::Problem>, canonicalization_problems: Vec<roc_problem::can::Problem>,
module_docs: ModuleDocumentation, module_docs: ModuleDocumentation,
}, },
SolvedTypes { SolvedTypes {
src: &'a str,
module_id: ModuleId, module_id: ModuleId,
ident_ids: IdentIds, ident_ids: IdentIds,
solved_module: SolvedModule, solved_module: SolvedModule,
@ -515,7 +515,6 @@ enum Msg<'a> {
solved_subs: Solved<Subs>, solved_subs: Solved<Subs>,
exposed_vars_by_symbol: Vec<(Symbol, Variable)>, exposed_vars_by_symbol: Vec<(Symbol, Variable)>,
documentation: MutMap<ModuleId, ModuleDocumentation>, documentation: MutMap<ModuleId, ModuleDocumentation>,
src: &'a str,
}, },
FoundSpecializations { FoundSpecializations {
module_id: ModuleId, module_id: ModuleId,
@ -524,7 +523,6 @@ enum Msg<'a> {
procs: Procs<'a>, procs: Procs<'a>,
problems: Vec<roc_mono::ir::MonoProblem>, problems: Vec<roc_mono::ir::MonoProblem>,
solved_subs: Solved<Subs>, solved_subs: Solved<Subs>,
finished_info: FinishedInfo<'a>,
}, },
MadeSpecializations { MadeSpecializations {
module_id: ModuleId, module_id: ModuleId,
@ -534,7 +532,6 @@ enum Msg<'a> {
procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>, procedures: MutMap<(Symbol, Layout<'a>), Proc<'a>>,
problems: Vec<roc_mono::ir::MonoProblem>, problems: Vec<roc_mono::ir::MonoProblem>,
subs: Subs, subs: Subs,
finished_info: FinishedInfo<'a>,
}, },
/// The task is to only typecheck AND monomorphize modules /// The task is to only typecheck AND monomorphize modules
@ -542,16 +539,9 @@ enum Msg<'a> {
FinishedAllSpecialization { FinishedAllSpecialization {
subs: Subs, subs: Subs,
exposed_to_host: MutMap<Symbol, Variable>, exposed_to_host: MutMap<Symbol, Variable>,
src: &'a str,
}, },
} }
#[derive(Debug)]
pub struct FinishedInfo<'a> {
exposed_vars_by_symbol: Vec<(Symbol, Variable)>,
src: &'a str,
}
#[derive(Debug)] #[derive(Debug)]
struct State<'a> { struct State<'a> {
pub root_id: ModuleId, pub root_id: ModuleId,
@ -559,10 +549,7 @@ struct State<'a> {
pub stdlib: StdLib, pub stdlib: StdLib,
pub exposed_types: SubsByModule, pub exposed_types: SubsByModule,
pub can_problems: std::vec::Vec<roc_problem::can::Problem>,
pub mono_problems: std::vec::Vec<MonoProblem>,
pub headers_parsed: MutSet<ModuleId>, pub headers_parsed: MutSet<ModuleId>,
pub type_problems: std::vec::Vec<solve::TypeError>,
pub module_cache: ModuleCache<'a>, pub module_cache: ModuleCache<'a>,
pub dependencies: Dependencies, pub dependencies: Dependencies,
@ -702,7 +689,6 @@ enum BuildTask<'a> {
constraint: Constraint, constraint: Constraint,
var_store: VarStore, var_store: VarStore,
declarations: Vec<Declaration>, declarations: Vec<Declaration>,
src: &'a str,
}, },
BuildPendingSpecializations { BuildPendingSpecializations {
module_timing: ModuleTiming, module_timing: ModuleTiming,
@ -711,7 +697,6 @@ enum BuildTask<'a> {
module_id: ModuleId, module_id: ModuleId,
ident_ids: IdentIds, ident_ids: IdentIds,
decls: Vec<Declaration>, decls: Vec<Declaration>,
finished_info: FinishedInfo<'a>,
exposed_to_host: MutMap<Symbol, Variable>, exposed_to_host: MutMap<Symbol, Variable>,
}, },
MakeSpecializations { MakeSpecializations {
@ -720,7 +705,6 @@ enum BuildTask<'a> {
subs: Subs, subs: Subs,
procs: Procs<'a>, procs: Procs<'a>,
layout_cache: LayoutCache<'a>, layout_cache: LayoutCache<'a>,
finished_info: FinishedInfo<'a>,
specializations_we_must_make: ExternalSpecializations, specializations_we_must_make: ExternalSpecializations,
}, },
} }
@ -1105,9 +1089,6 @@ where
exposed_types, exposed_types,
headers_parsed, headers_parsed,
loading_started, loading_started,
can_problems: std::vec::Vec::new(),
type_problems: std::vec::Vec::new(),
mono_problems: std::vec::Vec::new(),
arc_modules, arc_modules,
constrained_ident_ids: IdentIds::exposed_builtins(0), constrained_ident_ids: IdentIds::exposed_builtins(0),
ident_ids_by_module, ident_ids_by_module,
@ -1140,7 +1121,6 @@ where
solved_subs, solved_subs,
exposed_vars_by_symbol, exposed_vars_by_symbol,
documentation, documentation,
src,
} => { } => {
// We're done! There should be no more messages pending. // We're done! There should be no more messages pending.
debug_assert!(msg_rx.is_empty()); debug_assert!(msg_rx.is_empty());
@ -1157,13 +1137,11 @@ where
solved_subs, solved_subs,
exposed_vars_by_symbol, exposed_vars_by_symbol,
documentation, documentation,
src,
))); )));
} }
Msg::FinishedAllSpecialization { Msg::FinishedAllSpecialization {
subs, subs,
exposed_to_host, exposed_to_host,
src,
} => { } => {
// We're done! There should be no more messages pending. // We're done! There should be no more messages pending.
debug_assert!(msg_rx.is_empty()); debug_assert!(msg_rx.is_empty());
@ -1179,7 +1157,6 @@ where
state, state,
subs, subs,
exposed_to_host, exposed_to_host,
src,
))); )));
} }
msg => { msg => {
@ -1267,6 +1244,11 @@ fn update<'a>(
Ok(state) Ok(state)
} }
Parsed(parsed) => { Parsed(parsed) => {
state
.module_cache
.sources
.insert(parsed.module_id, (parsed.module_path.clone(), parsed.src));
let module_id = parsed.module_id; let module_id = parsed.module_id;
state.module_cache.parsed.insert(parsed.module_id, parsed); state.module_cache.parsed.insert(parsed.module_id, parsed);
@ -1288,7 +1270,10 @@ fn update<'a>(
} => { } => {
let module_id = constrained_module.module.module_id; let module_id = constrained_module.module.module_id;
log!("generated constraints for {:?}", module_id); log!("generated constraints for {:?}", module_id);
state.can_problems.extend(canonicalization_problems); state
.module_cache
.can_problems
.insert(module_id, canonicalization_problems);
state state
.module_cache .module_cache
@ -1318,7 +1303,6 @@ fn update<'a>(
Ok(state) Ok(state)
} }
SolvedTypes { SolvedTypes {
src,
module_id, module_id,
ident_ids, ident_ids,
solved_module, solved_module,
@ -1329,7 +1313,10 @@ fn update<'a>(
log!("solved types for {:?}", module_id); log!("solved types for {:?}", module_id);
module_timing.end_time = SystemTime::now(); module_timing.end_time = SystemTime::now();
state.type_problems.extend(solved_module.problems); state
.module_cache
.type_problems
.insert(module_id, solved_module.problems);
let work = state.dependencies.notify(module_id, Phase::SolveTypes); let work = state.dependencies.notify(module_id, Phase::SolveTypes);
@ -1357,7 +1344,6 @@ fn update<'a>(
solved_subs, solved_subs,
exposed_vars_by_symbol: solved_module.exposed_vars_by_symbol, exposed_vars_by_symbol: solved_module.exposed_vars_by_symbol,
documentation, documentation,
src,
}) })
.map_err(|_| LoadingProblem::MsgChannelDied)?; .map_err(|_| LoadingProblem::MsgChannelDied)?;
@ -1382,11 +1368,6 @@ fn update<'a>(
if state.goal_phase > Phase::SolveTypes { if state.goal_phase > Phase::SolveTypes {
let layout_cache = state.layout_caches.pop().unwrap_or_default(); let layout_cache = state.layout_caches.pop().unwrap_or_default();
let finished_info = FinishedInfo {
src,
exposed_vars_by_symbol: solved_module.exposed_vars_by_symbol,
};
let typechecked = TypeCheckedModule { let typechecked = TypeCheckedModule {
module_id, module_id,
decls, decls,
@ -1394,7 +1375,6 @@ fn update<'a>(
ident_ids, ident_ids,
module_timing, module_timing,
layout_cache, layout_cache,
finished_info,
}; };
state state
@ -1417,7 +1397,6 @@ fn update<'a>(
FoundSpecializations { FoundSpecializations {
module_id, module_id,
procs, procs,
finished_info,
solved_subs, solved_subs,
ident_ids, ident_ids,
layout_cache, layout_cache,
@ -1443,7 +1422,6 @@ fn update<'a>(
layout_cache, layout_cache,
module_id, module_id,
procs, procs,
finished_info,
ident_ids, ident_ids,
subs, subs,
}; };
@ -1468,7 +1446,6 @@ fn update<'a>(
module_id, module_id,
ident_ids, ident_ids,
subs, subs,
finished_info,
procedures, procedures,
external_specializations_requested, external_specializations_requested,
problems, problems,
@ -1476,7 +1453,7 @@ fn update<'a>(
} => { } => {
log!("made specializations for {:?}", module_id); log!("made specializations for {:?}", module_id);
state.mono_problems.extend(problems); state.module_cache.mono_problems.insert(module_id, problems);
for (module_id, requested) in external_specializations_requested { for (module_id, requested) in external_specializations_requested {
let existing = match state let existing = match state
@ -1512,7 +1489,6 @@ fn update<'a>(
subs, subs,
// TODO thread through mono problems // TODO thread through mono problems
exposed_to_host: state.exposed_to_host.clone(), exposed_to_host: state.exposed_to_host.clone(),
src: finished_info.src,
}) })
.map_err(|_| LoadingProblem::MsgChannelDied)?; .map_err(|_| LoadingProblem::MsgChannelDied)?;
@ -1542,7 +1518,6 @@ fn finish_specialization<'a>(
state: State<'a>, state: State<'a>,
subs: Subs, subs: Subs,
exposed_to_host: MutMap<Symbol, Variable>, exposed_to_host: MutMap<Symbol, Variable>,
src: &'a str,
) -> MonomorphizedModule<'a> { ) -> MonomorphizedModule<'a> {
let module_ids = Arc::try_unwrap(state.arc_modules) let module_ids = Arc::try_unwrap(state.arc_modules)
.unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids")) .unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids"))
@ -1554,12 +1529,23 @@ fn finish_specialization<'a>(
}; };
let State { let State {
procedures,
module_cache,
..
} = state;
let ModuleCache {
mono_problems, mono_problems,
type_problems, type_problems,
can_problems, can_problems,
procedures, sources,
.. ..
} = state; } = module_cache;
let sources = sources
.into_iter()
.map(|(id, (path, src))| (id, (path, src.into())))
.collect();
MonomorphizedModule { MonomorphizedModule {
can_problems, can_problems,
@ -1570,7 +1556,8 @@ fn finish_specialization<'a>(
subs, subs,
interns, interns,
procedures, procedures,
src: src.into(), // src: src.into(),
sources,
timings: state.timings, timings: state.timings,
} }
} }
@ -1580,7 +1567,6 @@ fn finish<'a>(
solved: Solved<Subs>, solved: Solved<Subs>,
exposed_vars_by_symbol: Vec<(Symbol, Variable)>, exposed_vars_by_symbol: Vec<(Symbol, Variable)>,
documentation: MutMap<ModuleId, ModuleDocumentation>, documentation: MutMap<ModuleId, ModuleDocumentation>,
src: &'a str,
) -> LoadedModule { ) -> LoadedModule {
let module_ids = Arc::try_unwrap(state.arc_modules) let module_ids = Arc::try_unwrap(state.arc_modules)
.unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids")) .unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids"))
@ -1591,15 +1577,22 @@ fn finish<'a>(
all_ident_ids: state.constrained_ident_ids, all_ident_ids: state.constrained_ident_ids,
}; };
let sources = state
.module_cache
.sources
.into_iter()
.map(|(id, (path, src))| (id, (path, src.into())))
.collect();
LoadedModule { LoadedModule {
module_id: state.root_id, module_id: state.root_id,
interns, interns,
solved, solved,
can_problems: state.can_problems, can_problems: state.module_cache.can_problems,
type_problems: state.type_problems, type_problems: state.module_cache.type_problems,
declarations_by_id: state.declarations_by_id, declarations_by_id: state.declarations_by_id,
exposed_to_host: exposed_vars_by_symbol.into_iter().collect(), exposed_to_host: exposed_vars_by_symbol.into_iter().collect(),
src: src.into(), sources,
timings: state.timings, timings: state.timings,
documentation, documentation,
} }
@ -1693,6 +1686,7 @@ fn parse_header<'a>(
match parsed { match parsed {
Ok((ast::Module::Interface { header }, parse_state)) => Ok(send_header( Ok((ast::Module::Interface { header }, parse_state)) => Ok(send_header(
header.name, header.name,
filename,
header.exposes.into_bump_slice(), header.exposes.into_bump_slice(),
header.imports.into_bump_slice(), header.imports.into_bump_slice(),
parse_state, parse_state,
@ -1702,6 +1696,7 @@ fn parse_header<'a>(
)), )),
Ok((ast::Module::App { header }, parse_state)) => Ok(send_header( Ok((ast::Module::App { header }, parse_state)) => Ok(send_header(
header.name, header.name,
filename,
header.provides.into_bump_slice(), header.provides.into_bump_slice(),
header.imports.into_bump_slice(), header.imports.into_bump_slice(),
parse_state, parse_state,
@ -1776,6 +1771,7 @@ fn load_from_str<'a>(
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn send_header<'a>( fn send_header<'a>(
name: Located<roc_parse::header::ModuleName<'a>>, name: Located<roc_parse::header::ModuleName<'a>>,
filename: PathBuf,
exposes: &'a [Located<ExposesEntry<'a>>], exposes: &'a [Located<ExposesEntry<'a>>],
imports: &'a [Located<ImportsEntry<'a>>], imports: &'a [Located<ImportsEntry<'a>>],
parse_state: parser::State<'a>, parse_state: parser::State<'a>,
@ -1895,6 +1891,7 @@ fn send_header<'a>(
home, home,
Msg::Header(ModuleHeader { Msg::Header(ModuleHeader {
module_id: home, module_id: home,
module_path: filename,
exposed_ident_ids: ident_ids, exposed_ident_ids: ident_ids,
module_name: declared_name, module_name: declared_name,
imported_modules, imported_modules,
@ -1914,7 +1911,6 @@ impl<'a> BuildTask<'a> {
module: Module, module: Module,
ident_ids: IdentIds, ident_ids: IdentIds,
module_timing: ModuleTiming, module_timing: ModuleTiming,
src: &'a str,
constraint: Constraint, constraint: Constraint,
var_store: VarStore, var_store: VarStore,
imported_modules: MutSet<ModuleId>, imported_modules: MutSet<ModuleId>,
@ -1954,7 +1950,6 @@ impl<'a> BuildTask<'a> {
imported_symbols, imported_symbols,
constraint, constraint,
var_store, var_store,
src,
declarations, declarations,
module_timing, module_timing,
} }
@ -1970,7 +1965,6 @@ fn run_solve<'a>(
constraint: Constraint, constraint: Constraint,
mut var_store: VarStore, mut var_store: VarStore,
decls: Vec<Declaration>, decls: Vec<Declaration>,
src: &'a str,
) -> Msg<'a> { ) -> Msg<'a> {
// We have more constraining work to do now, so we'll add it to our timings. // We have more constraining work to do now, so we'll add it to our timings.
let constrain_start = SystemTime::now(); let constrain_start = SystemTime::now();
@ -2012,7 +2006,6 @@ fn run_solve<'a>(
// Send the subs to the main thread for processing, // Send the subs to the main thread for processing,
Msg::SolvedTypes { Msg::SolvedTypes {
src,
module_id, module_id,
solved_subs, solved_subs,
ident_ids, ident_ids,
@ -2041,7 +2034,6 @@ fn canonicalize_and_constrain<'a>(
exposed_imports, exposed_imports,
imported_modules, imported_modules,
mut module_timing, mut module_timing,
src,
.. ..
} = parsed; } = parsed;
@ -2094,7 +2086,6 @@ fn canonicalize_and_constrain<'a>(
module, module,
declarations: module_output.declarations, declarations: module_output.declarations,
imported_modules, imported_modules,
src,
var_store, var_store,
constraint, constraint,
ident_ids: module_output.ident_ids, ident_ids: module_output.ident_ids,
@ -2145,12 +2136,14 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result<Msg<'a>, Loadi
deps_by_name, deps_by_name,
exposed_ident_ids, exposed_ident_ids,
exposed_imports, exposed_imports,
module_path,
.. ..
} = header; } = header;
let parsed = ParsedModule { let parsed = ParsedModule {
module_id, module_id,
module_name, module_name,
module_path,
deps_by_name, deps_by_name,
exposed_ident_ids, exposed_ident_ids,
exposed_imports, exposed_imports,
@ -2202,7 +2195,6 @@ fn make_specializations<'a>(
mut procs: Procs<'a>, mut procs: Procs<'a>,
mut layout_cache: LayoutCache<'a>, mut layout_cache: LayoutCache<'a>,
specializations_we_must_make: ExternalSpecializations, specializations_we_must_make: ExternalSpecializations,
finished_info: FinishedInfo<'a>,
) -> Msg<'a> { ) -> Msg<'a> {
let mut mono_problems = Vec::new(); let mut mono_problems = Vec::new();
// do the thing // do the thing
@ -2238,7 +2230,6 @@ fn make_specializations<'a>(
procedures, procedures,
problems: mono_problems, problems: mono_problems,
subs, subs,
finished_info,
external_specializations_requested, external_specializations_requested,
} }
} }
@ -2255,7 +2246,6 @@ fn build_pending_specializations<'a>(
mut layout_cache: LayoutCache<'a>, mut layout_cache: LayoutCache<'a>,
// TODO remove // TODO remove
exposed_to_host: MutMap<Symbol, Variable>, exposed_to_host: MutMap<Symbol, Variable>,
finished_info: FinishedInfo<'a>,
) -> Msg<'a> { ) -> Msg<'a> {
let mut procs = Procs::default(); let mut procs = Procs::default();
@ -2309,7 +2299,6 @@ fn build_pending_specializations<'a>(
layout_cache, layout_cache,
procs, procs,
problems, problems,
finished_info,
} }
} }
@ -2457,7 +2446,6 @@ fn run_task<'a>(
var_store, var_store,
ident_ids, ident_ids,
declarations, declarations,
src,
} => Ok(run_solve( } => Ok(run_solve(
module, module,
ident_ids, ident_ids,
@ -2466,7 +2454,6 @@ fn run_task<'a>(
constraint, constraint,
var_store, var_store,
declarations, declarations,
src,
)), )),
BuildPendingSpecializations { BuildPendingSpecializations {
module_id, module_id,
@ -2475,7 +2462,6 @@ fn run_task<'a>(
module_timing, module_timing,
layout_cache, layout_cache,
solved_subs, solved_subs,
finished_info,
exposed_to_host, exposed_to_host,
} => Ok(build_pending_specializations( } => Ok(build_pending_specializations(
arena, arena,
@ -2486,7 +2472,6 @@ fn run_task<'a>(
module_timing, module_timing,
layout_cache, layout_cache,
exposed_to_host, exposed_to_host,
finished_info,
)), )),
MakeSpecializations { MakeSpecializations {
module_id, module_id,
@ -2495,7 +2480,6 @@ fn run_task<'a>(
procs, procs,
layout_cache, layout_cache,
specializations_we_must_make, specializations_we_must_make,
finished_info,
} => Ok(make_specializations( } => Ok(make_specializations(
arena, arena,
module_id, module_id,
@ -2504,7 +2488,6 @@ fn run_task<'a>(
procs, procs,
layout_cache, layout_cache,
specializations_we_must_make, specializations_we_must_make,
finished_info,
)), )),
}?; }?;

View file

@ -43,10 +43,21 @@ mod test_load {
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
); );
let loaded_module = loaded.expect("Test module failed to load"); let mut loaded_module = loaded.expect("Test module failed to load");
assert_eq!(loaded_module.can_problems, Vec::new()); let home = loaded_module.module_id;
assert_eq!(loaded_module.type_problems, Vec::new());
assert_eq!(
loaded_module.can_problems.remove(&home).unwrap_or_default(),
Vec::new()
);
assert_eq!(
loaded_module
.type_problems
.remove(&home)
.unwrap_or_default(),
Vec::new()
);
let expected_name = loaded_module let expected_name = loaded_module
.interns .interns
@ -87,8 +98,17 @@ mod test_load {
let home = loaded_module.module_id; let home = loaded_module.module_id;
let mut subs = loaded_module.solved.into_inner(); let mut subs = loaded_module.solved.into_inner();
assert_eq!(loaded_module.can_problems, Vec::new()); assert_eq!(
assert_eq!(loaded_module.type_problems, Vec::new()); loaded_module.can_problems.remove(&home).unwrap_or_default(),
Vec::new()
);
assert_eq!(
loaded_module
.type_problems
.remove(&home)
.unwrap_or_default(),
Vec::new()
);
for decl in loaded_module.declarations_by_id.remove(&home).unwrap() { for decl in loaded_module.declarations_by_id.remove(&home).unwrap() {
match decl { match decl {
@ -141,9 +161,19 @@ mod test_load {
); );
let mut loaded_module = loaded.expect("Test module failed to load"); let mut loaded_module = loaded.expect("Test module failed to load");
let home = loaded_module.module_id;
assert_eq!(loaded_module.can_problems, Vec::new()); assert_eq!(
assert_eq!(loaded_module.type_problems, Vec::new()); loaded_module.can_problems.remove(&home).unwrap_or_default(),
Vec::new()
);
assert_eq!(
loaded_module
.type_problems
.remove(&home)
.unwrap_or_default(),
Vec::new()
);
let def_count: usize = loaded_module let def_count: usize = loaded_module
.declarations_by_id .declarations_by_id

View file

@ -44,10 +44,21 @@ mod test_uniq_load {
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
); );
let loaded_module = loaded.expect("Test module failed to load"); let mut loaded_module = loaded.expect("Test module failed to load");
assert_eq!(loaded_module.can_problems, Vec::new()); let home = loaded_module.module_id;
assert_eq!(loaded_module.type_problems, Vec::new());
assert_eq!(
loaded_module.can_problems.remove(&home).unwrap_or_default(),
Vec::new()
);
assert_eq!(
loaded_module
.type_problems
.remove(&home)
.unwrap_or_default(),
Vec::new()
);
let expected_name = loaded_module let expected_name = loaded_module
.interns .interns
@ -88,8 +99,17 @@ mod test_uniq_load {
let home = loaded_module.module_id; let home = loaded_module.module_id;
let mut subs = loaded_module.solved.into_inner(); let mut subs = loaded_module.solved.into_inner();
assert_eq!(loaded_module.can_problems, Vec::new()); assert_eq!(
assert_eq!(loaded_module.type_problems, Vec::new()); loaded_module.can_problems.remove(&home).unwrap_or_default(),
Vec::new()
);
assert_eq!(
loaded_module
.type_problems
.remove(&home)
.unwrap_or_default(),
Vec::new()
);
for decl in loaded_module.declarations_by_id.remove(&home).unwrap() { for decl in loaded_module.declarations_by_id.remove(&home).unwrap() {
match decl { match decl {
@ -142,9 +162,19 @@ mod test_uniq_load {
); );
let mut loaded_module = loaded.expect("Test module failed to load"); let mut loaded_module = loaded.expect("Test module failed to load");
let home = loaded_module.module_id;
assert_eq!(loaded_module.can_problems, Vec::new()); assert_eq!(
assert_eq!(loaded_module.type_problems, Vec::new()); loaded_module.can_problems.remove(&home).unwrap_or_default(),
Vec::new()
);
assert_eq!(
loaded_module
.type_problems
.remove(&home)
.unwrap_or_default(),
Vec::new()
);
let def_count: usize = loaded_module let def_count: usize = loaded_module
.declarations_by_id .declarations_by_id

View file

@ -62,18 +62,20 @@ mod test_mono {
exposed_types, exposed_types,
); );
let loaded = loaded.expect("failed to load module"); let mut loaded = loaded.expect("failed to load module");
use roc_load::file::MonomorphizedModule; use roc_load::file::MonomorphizedModule;
let MonomorphizedModule { let MonomorphizedModule {
can_problems, module_id: home,
type_problems,
mono_problems,
procedures, procedures,
exposed_to_host, exposed_to_host,
.. ..
} = loaded; } = loaded;
let can_problems = loaded.can_problems.remove(&home).unwrap_or_default();
let type_problems = loaded.type_problems.remove(&home).unwrap_or_default();
let mono_problems = loaded.mono_problems.remove(&home).unwrap_or_default();
if !can_problems.is_empty() { if !can_problems.is_empty() {
println!("Ignoring {} canonicalization problems", can_problems.len()); println!("Ignoring {} canonicalization problems", can_problems.len());
} }

View file

@ -75,13 +75,16 @@ mod solve_expr {
let LoadedModule { let LoadedModule {
module_id: home, module_id: home,
mut can_problems, mut can_problems,
type_problems, mut type_problems,
interns, interns,
mut solved, mut solved,
exposed_to_host, exposed_to_host,
.. ..
} = loaded; } = loaded;
let mut can_problems = can_problems.remove(&home).unwrap_or_default();
let type_problems = type_problems.remove(&home).unwrap_or_default();
let mut subs = solved.inner_mut(); let mut subs = solved.inner_mut();
// assert!(can_problems.is_empty()); // assert!(can_problems.is_empty());