mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Merge remote-tracking branch 'remote/main' into upgrade-llvm-zig
This commit is contained in:
commit
2feb5d3c2e
426 changed files with 8889 additions and 4190 deletions
|
@ -6,7 +6,7 @@ use roc_can::constraint::{Constraint, Constraints};
|
|||
use roc_can::expr::PendingDerives;
|
||||
use roc_can::module::{ExposedByModule, ModuleParams, ResolvedImplementations, RigidVariables};
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_collections::VecMap;
|
||||
use roc_collections::{VecMap, VecSet};
|
||||
use roc_derive::SharedDerivedModule;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
|
@ -76,6 +76,8 @@ pub struct SolveConfig<'a> {
|
|||
/// Needed during solving to resolve lambda sets from derived implementations that escape into
|
||||
/// the user module.
|
||||
pub derived_module: SharedDerivedModule,
|
||||
/// Symbols that are exposed to the host which might need special treatment.
|
||||
pub host_exposed_symbols: Option<&'a VecSet<Symbol>>,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
/// The checkmate collector for this module.
|
||||
|
|
|
@ -19,7 +19,7 @@ use roc_can::constraint::{
|
|||
};
|
||||
use roc_can::expected::{Expected, PExpected};
|
||||
use roc_can::module::ModuleParams;
|
||||
use roc_collections::VecMap;
|
||||
use roc_collections::{VecMap, VecSet};
|
||||
use roc_debug_flags::dbg_do;
|
||||
#[cfg(debug_assertions)]
|
||||
use roc_debug_flags::ROC_VERIFY_RIGID_LET_GENERALIZED;
|
||||
|
@ -136,6 +136,7 @@ fn run_help(
|
|||
function_kind,
|
||||
module_params,
|
||||
module_params_vars,
|
||||
host_exposed_symbols,
|
||||
..
|
||||
} = config;
|
||||
|
||||
|
@ -190,6 +191,7 @@ fn run_help(
|
|||
&mut awaiting_specializations,
|
||||
module_params,
|
||||
module_params_vars,
|
||||
host_exposed_symbols,
|
||||
);
|
||||
|
||||
RunSolveOutput {
|
||||
|
@ -249,6 +251,7 @@ fn solve(
|
|||
awaiting_specializations: &mut AwaitingSpecializations,
|
||||
module_params: Option<ModuleParams>,
|
||||
module_params_vars: VecMap<ModuleId, Variable>,
|
||||
host_exposed_symbols: Option<&VecSet<Symbol>>,
|
||||
) -> State {
|
||||
let scope = Scope::new(module_params);
|
||||
|
||||
|
@ -455,6 +458,7 @@ fn solve(
|
|||
solve_suffix_fx(
|
||||
env,
|
||||
problems,
|
||||
host_exposed_symbols,
|
||||
FxSuffixKind::Let(*symbol),
|
||||
loc_var.value,
|
||||
&loc_var.region,
|
||||
|
@ -853,7 +857,7 @@ fn solve(
|
|||
*type_index,
|
||||
);
|
||||
|
||||
solve_suffix_fx(env, problems, *kind, actual, region);
|
||||
solve_suffix_fx(env, problems, host_exposed_symbols, *kind, actual, region);
|
||||
state
|
||||
}
|
||||
ExpectEffectful(variable, reason, region) => {
|
||||
|
@ -1625,6 +1629,7 @@ fn solve(
|
|||
fn solve_suffix_fx(
|
||||
env: &mut InferenceEnv<'_>,
|
||||
problems: &mut Vec<TypeError>,
|
||||
host_exposed_symbols: Option<&VecSet<Symbol>>,
|
||||
kind: FxSuffixKind,
|
||||
variable: Variable,
|
||||
region: &Region,
|
||||
|
@ -1651,7 +1656,16 @@ fn solve_suffix_fx(
|
|||
let fx = *fx;
|
||||
match env.subs.get_content_without_compacting(fx) {
|
||||
Content::Pure => {
|
||||
problems.push(TypeError::SuffixedPureFunction(*region, kind));
|
||||
match (kind.symbol(), host_exposed_symbols) {
|
||||
(Some(sym), Some(host_exposed)) if host_exposed.contains(sym) => {
|
||||
// If exposed to the platform, it's allowed to be suffixed but pure
|
||||
// The platform might require a `main!` function that could perform
|
||||
// effects, but that's not a requirement.
|
||||
}
|
||||
_ => {
|
||||
problems.push(TypeError::SuffixedPureFunction(*region, kind));
|
||||
}
|
||||
}
|
||||
}
|
||||
Content::FlexVar(_) => {
|
||||
env.subs.set_content(fx, Content::Effectful);
|
||||
|
|
|
@ -3863,7 +3863,7 @@ mod solve_expr {
|
|||
#[test]
|
||||
fn list_split() {
|
||||
infer_eq_without_problem(
|
||||
indoc!("List.split"),
|
||||
indoc!("List.splitAt"),
|
||||
"List elem, U64 -> { before : List elem, others : List elem }",
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue