fix problem with specializing rigids

This commit is contained in:
Folkert 2020-10-14 02:21:33 +02:00
parent 6aaba98d31
commit f07fe1879b
5 changed files with 28 additions and 9 deletions

View file

@ -530,6 +530,24 @@ mod gen_primitives {
#[test]
#[ignore]
fn top_level_constant() {
assert_evals_to!(
indoc!(
r#"
app LinkedListLen0 provides [ main ] imports []
pi = 3.1415
main =
pi + pi
"#
),
3.1415 + 3.1415,
f64
);
}
#[test]
fn linked_list_len_0() {
assert_evals_to!(
indoc!(
@ -538,8 +556,8 @@ mod gen_primitives {
LinkedList a : [ Nil, Cons a (LinkedList a) ]
nil : LinkedList Int
nil = Nil
nil : {} -> LinkedList Int
nil = \_ -> Nil
length : LinkedList a -> Int
length = \list ->
@ -549,7 +567,7 @@ mod gen_primitives {
main =
length nil
length (nil {})
"#
),
0,

View file

@ -282,7 +282,7 @@ macro_rules! assert_evals_to {
// parsing the source, so that there's no chance their passing
// or failing depends on leftover state from the previous one.
{
//assert_llvm_evals_to!($src, $expected, $ty, $transform, $leak);
assert_llvm_evals_to!($src, $expected, $ty, $transform, $leak);
}
{
assert_opt_evals_to!($src, $expected, $ty, $transform, $leak);

View file

@ -1365,10 +1365,12 @@ fn specialize_external<'a>(
// unify the called function with the specialized signature, then specialize the function body
let snapshot = env.subs.snapshot();
let cache_snapshot = layout_cache.snapshot();
let unified = roc_unify::unify::unify(env.subs, annotation, fn_var);
debug_assert!(matches!(unified, roc_unify::unify::Unified::Success(_)));
let is_valid = matches!(unified, roc_unify::unify::Unified::Success(_));
debug_assert!(is_valid);
let specialized_body = from_can(env, body, procs, layout_cache);
@ -1376,6 +1378,7 @@ fn specialize_external<'a>(
build_specialized_proc_from_var(env, layout_cache, pattern_symbols, fn_var)?;
// reset subs, so we don't get type errors when specializing for a different signature
layout_cache.rollback_to(cache_snapshot);
env.subs.rollback_to(snapshot);
// TODO WRONG

View file

@ -1227,8 +1227,6 @@ fn instantiate_rigids_help(
if let Some(copy) = desc.copy.into_variable() {
return copy;
} else if desc.rank != Rank::NONE {
return var;
}
let make_descriptor = |content| Descriptor {

View file

@ -681,7 +681,7 @@ fn unify_shared_tags(
merge(subs, ctx, Structure(flat_type))
} else {
mismatch!()
mismatch!("Problem with Tag Union")
}
}
@ -911,7 +911,7 @@ fn unify_rigid(subs: &mut Subs, ctx: &Context, name: &Lowercase, other: &Content
RigidVar(_) | Structure(_) | Alias(_, _, _) => {
// Type mismatch! Rigid can only unify with flex, even if the
// rigid names are the same.
mismatch!()
mismatch!("Rigid with {:?}", &other)
}
Error => {
// Error propagates.