mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-03 06:02:54 +00:00
Merge remote-tracking branch 'origin/main' into rust-1-62-1
This commit is contained in:
commit
14cd48fce7
685 changed files with 44531 additions and 20189 deletions
|
|
@ -51,6 +51,16 @@ fn module_source_and_path(builtin: DeriveBuiltin) -> (ModuleId, &'static str, Pa
|
|||
module_source(ModuleId::DECODE),
|
||||
builtins_path.join("Decode.roc"),
|
||||
),
|
||||
DeriveBuiltin::Hash => (
|
||||
ModuleId::HASH,
|
||||
module_source(ModuleId::HASH),
|
||||
builtins_path.join("Hash.roc"),
|
||||
),
|
||||
DeriveBuiltin::IsEq => (
|
||||
ModuleId::BOOL,
|
||||
module_source(ModuleId::BOOL),
|
||||
builtins_path.join("Bool.roc"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +144,7 @@ macro_rules! v {
|
|||
use roc_module::symbol::Symbol;
|
||||
|subs: &mut Subs| {
|
||||
let args = vec![$( $arg(subs) )*];
|
||||
let alias_variables = AliasVariables::insert_into_subs::<Vec<_>, Vec<_>>(subs, args, vec![]);
|
||||
let alias_variables = AliasVariables::insert_into_subs::<Vec<_>, Vec<_>, _>(subs, args, vec![], vec![]);
|
||||
let real_var = $real_var(subs);
|
||||
roc_derive::synth_var(subs, Content::Alias(Symbol::$alias, alias_variables, real_var, AliasKind::Structural))
|
||||
}
|
||||
|
|
@ -145,7 +155,7 @@ macro_rules! v {
|
|||
use roc_module::symbol::Symbol;
|
||||
|subs: &mut Subs| {
|
||||
let args = vec![$( $arg(subs) )*];
|
||||
let alias_variables = AliasVariables::insert_into_subs::<Vec<_>, Vec<_>>(subs, args, vec![]);
|
||||
let alias_variables = AliasVariables::insert_into_subs::<Vec<_>, Vec<_>, _>(subs, args, vec![], vec![]);
|
||||
let real_var = $real_var(subs);
|
||||
roc_derive::synth_var(subs, Content::Alias(Symbol::$alias, alias_variables, real_var, AliasKind::Opaque))
|
||||
}
|
||||
|
|
@ -155,12 +165,14 @@ macro_rules! v {
|
|||
|subs: &mut Subs| { roc_derive::synth_var(subs, Content::FlexVar(None)) }
|
||||
}};
|
||||
($name:ident has $ability:path) => {{
|
||||
use roc_types::subs::{Subs, SubsIndex, Content};
|
||||
use roc_types::subs::{Subs, SubsIndex, SubsSlice, Content};
|
||||
|subs: &mut Subs| {
|
||||
let name_index =
|
||||
SubsIndex::push_new(&mut subs.field_names, stringify!($name).into());
|
||||
|
||||
roc_derive::synth_var(subs, Content::FlexAbleVar(Some(name_index), $ability))
|
||||
let abilities_slice = SubsSlice::extend_new(&mut subs.symbol_names, [$ability]);
|
||||
|
||||
roc_derive::synth_var(subs, Content::FlexAbleVar(Some(name_index), abilities_slice))
|
||||
}
|
||||
}};
|
||||
(^$rec_var:ident) => {{
|
||||
|
|
@ -248,6 +260,18 @@ where
|
|||
assert_eq!(key, Ok(Derived::Immediate(immediate)));
|
||||
}
|
||||
|
||||
pub(crate) fn check_single_lset_immediate<S>(builtin: DeriveBuiltin, synth: S, immediate: Symbol)
|
||||
where
|
||||
S: FnOnce(&mut Subs) -> Variable,
|
||||
{
|
||||
let mut subs = Subs::new();
|
||||
let var = synth(&mut subs);
|
||||
|
||||
let key = Derived::builtin(builtin, &subs, var);
|
||||
|
||||
assert_eq!(key, Ok(Derived::SingleLambdaSetImmediate(immediate)));
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn assemble_derived_golden(
|
||||
subs: &mut Subs,
|
||||
|
|
@ -268,6 +292,7 @@ fn assemble_derived_golden(
|
|||
DebugPrint {
|
||||
print_lambda_sets: true,
|
||||
print_only_under_alias,
|
||||
..DebugPrint::NOTHING
|
||||
},
|
||||
);
|
||||
subs.rollback_to(snapshot);
|
||||
|
|
@ -352,6 +377,7 @@ fn check_derived_typechecks_and_golden(
|
|||
let mut rigid_vars = Default::default();
|
||||
let (import_variables, abilities_store) = add_imports(
|
||||
test_module,
|
||||
&mut constraints,
|
||||
&mut test_subs,
|
||||
pending_abilities,
|
||||
&exposed_for_module,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue