give back the subs of the root module (for the repl)

This commit is contained in:
Folkert 2022-04-09 14:11:50 +02:00
parent 9d966d439f
commit a15ff20eec
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -633,6 +633,7 @@ struct PlatformData {
#[derive(Debug)] #[derive(Debug)]
struct State<'a> { struct State<'a> {
pub root_id: ModuleId, pub root_id: ModuleId,
pub root_subs: Option<Subs>,
pub platform_data: Option<PlatformData>, pub platform_data: Option<PlatformData>,
pub goal_phase: Phase, pub goal_phase: Phase,
pub exposed_types: ExposedByModule, pub exposed_types: ExposedByModule,
@ -688,6 +689,7 @@ impl<'a> State<'a> {
Self { Self {
root_id, root_id,
root_subs: None,
target_info, target_info,
platform_data: None, platform_data: None,
goal_phase, goal_phase,
@ -2153,6 +2155,14 @@ fn update<'a>(
existing.push(requested); existing.push(requested);
} }
// use the subs of the root module;
// this is used in the repl to find the type of `main`
let subs = if module_id == state.root_id {
subs
} else {
state.root_subs.clone().unwrap()
};
msg_tx msg_tx
.send(Msg::FinishedAllSpecialization { .send(Msg::FinishedAllSpecialization {
subs, subs,
@ -2165,6 +2175,12 @@ fn update<'a>(
// the originally requested module, we're all done! // the originally requested module, we're all done!
return Ok(state); return Ok(state);
} else { } else {
// record the subs of the root module;
// this is used in the repl to find the type of `main`
if module_id == state.root_id {
state.root_subs = Some(subs);
}
state.constrained_ident_ids.insert(module_id, ident_ids); state.constrained_ident_ids.insert(module_id, ident_ids);
for (module_id, requested) in external_specializations_requested { for (module_id, requested) in external_specializations_requested {