mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
Push checkmate through load
This commit is contained in:
parent
27dd9d03aa
commit
1282110ef5
14 changed files with 167 additions and 45 deletions
|
@ -1294,7 +1294,7 @@ impl DerivableVisitor for DeriveEq {
|
|||
// only Dec implements Eq.
|
||||
// TODO(checkmate): pass checkmate through
|
||||
let unified = unify(
|
||||
&mut with_checkmate!(None, {
|
||||
&mut with_checkmate!({
|
||||
on => UEnv::new(subs, None),
|
||||
off => UEnv::new(subs),
|
||||
}),
|
||||
|
@ -1430,7 +1430,7 @@ pub fn resolve_ability_specialization<R: AbilityResolver>(
|
|||
instantiate_rigids(subs, signature_var);
|
||||
let (_vars, must_implement_ability, _lambda_sets_to_specialize, _meta) = unify(
|
||||
// TODO(checkmate): pass checkmate through
|
||||
&mut with_checkmate!(None, {
|
||||
&mut with_checkmate!({
|
||||
on => UEnv::new(subs, None),
|
||||
off => UEnv::new(subs),
|
||||
}),
|
||||
|
|
|
@ -19,6 +19,8 @@ pub struct SolveEnv<'a> {
|
|||
pub derived_env: &'a DerivedEnv<'a>,
|
||||
pub subs: &'a mut Subs,
|
||||
pub pools: &'a mut Pools,
|
||||
#[cfg(debug_assertions)]
|
||||
pub checkmate: Option<roc_checkmate::Collector>,
|
||||
}
|
||||
|
||||
/// Environment necessary for inference.
|
||||
|
@ -94,9 +96,8 @@ impl<'a> InferenceEnv<'a> {
|
|||
|
||||
/// Retrieves an environment for unification.
|
||||
pub fn uenv(&mut self) -> UEnv {
|
||||
// TODO(checkmate): pass checkmate through
|
||||
with_checkmate!(None, {
|
||||
on => UEnv::new(self.subs, None),
|
||||
with_checkmate!({
|
||||
on => UEnv::new(self.subs, self.checkmate.as_mut()),
|
||||
off => UEnv::new(self.subs),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::solve::RunSolveOutput;
|
||||
use crate::FunctionKind;
|
||||
use crate::{aliases::Aliases, solve};
|
||||
use roc_can::abilities::{AbilitiesStore, ResolvedImpl};
|
||||
|
@ -75,6 +76,10 @@ pub struct SolveConfig<'a> {
|
|||
/// Needed during solving to resolve lambda sets from derived implementations that escape into
|
||||
/// the user module.
|
||||
pub derived_module: SharedDerivedModule,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
/// The checkmate collector for this module.
|
||||
pub checkmate: Option<roc_checkmate::Collector>,
|
||||
}
|
||||
|
||||
pub struct SolveOutput {
|
||||
|
@ -82,6 +87,9 @@ pub struct SolveOutput {
|
|||
pub scope: solve::Scope,
|
||||
pub errors: Vec<TypeError>,
|
||||
pub resolved_abilities_store: AbilitiesStore,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub checkmate: Option<roc_checkmate::Collector>,
|
||||
}
|
||||
|
||||
pub fn run_solve(
|
||||
|
@ -108,7 +116,12 @@ pub fn run_solve(
|
|||
let mut problems = Vec::new();
|
||||
|
||||
// Run the solver to populate Subs.
|
||||
let (solved_subs, solved_scope) = solve::run(
|
||||
let RunSolveOutput {
|
||||
solved,
|
||||
scope,
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
} = solve::run(
|
||||
config,
|
||||
&mut problems,
|
||||
subs,
|
||||
|
@ -117,10 +130,12 @@ pub fn run_solve(
|
|||
);
|
||||
|
||||
SolveOutput {
|
||||
subs: solved_subs,
|
||||
scope: solved_scope,
|
||||
subs: solved,
|
||||
scope,
|
||||
errors: problems,
|
||||
resolved_abilities_store: abilities_store,
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,27 +94,32 @@ struct State {
|
|||
mark: Mark,
|
||||
}
|
||||
|
||||
pub struct RunSolveOutput {
|
||||
pub solved: Solved<Subs>,
|
||||
pub scope: Scope,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub checkmate: Option<roc_checkmate::Collector>,
|
||||
}
|
||||
|
||||
pub fn run(
|
||||
config: SolveConfig,
|
||||
problems: &mut Vec<TypeError>,
|
||||
mut subs: Subs,
|
||||
subs: Subs,
|
||||
aliases: &mut Aliases,
|
||||
abilities_store: &mut AbilitiesStore,
|
||||
) -> (Solved<Subs>, Scope) {
|
||||
let env = run_in_place(config, problems, &mut subs, aliases, abilities_store);
|
||||
|
||||
(Solved(subs), env)
|
||||
) -> RunSolveOutput {
|
||||
run_help(config, problems, subs, aliases, abilities_store)
|
||||
}
|
||||
|
||||
/// Modify an existing subs in-place instead
|
||||
#[allow(clippy::too_many_arguments)] // TODO: put params in a context/env var
|
||||
fn run_in_place(
|
||||
fn run_help(
|
||||
config: SolveConfig,
|
||||
problems: &mut Vec<TypeError>,
|
||||
subs: &mut Subs,
|
||||
mut owned_subs: Subs,
|
||||
aliases: &mut Aliases,
|
||||
abilities_store: &mut AbilitiesStore,
|
||||
) -> Scope {
|
||||
) -> RunSolveOutput {
|
||||
let subs = &mut owned_subs;
|
||||
let SolveConfig {
|
||||
home: _,
|
||||
constraints,
|
||||
|
@ -124,6 +129,7 @@ fn run_in_place(
|
|||
exposed_by_module,
|
||||
derived_module,
|
||||
function_kind,
|
||||
..
|
||||
} = config;
|
||||
|
||||
let mut pools = Pools::default();
|
||||
|
@ -150,6 +156,8 @@ fn run_in_place(
|
|||
derived_env: &derived_env,
|
||||
subs,
|
||||
pools: &mut pools,
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate: config.checkmate,
|
||||
};
|
||||
|
||||
let pending_derives = PendingDerivesTable::new(
|
||||
|
@ -180,7 +188,12 @@ fn run_in_place(
|
|||
&mut awaiting_specializations,
|
||||
);
|
||||
|
||||
state.scope
|
||||
RunSolveOutput {
|
||||
scope: state.scope,
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate: env.checkmate,
|
||||
solved: Solved(owned_subs),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue