diff --git a/compiler/gen/tests/gen_primitives.rs b/compiler/gen/tests/gen_primitives.rs index 27dc2e7068..6a53c93974 100644 --- a/compiler/gen/tests/gen_primitives.rs +++ b/compiler/gen/tests/gen_primitives.rs @@ -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, diff --git a/compiler/gen/tests/helpers/eval.rs b/compiler/gen/tests/helpers/eval.rs index 5c80c14434..5377918cbb 100644 --- a/compiler/gen/tests/helpers/eval.rs +++ b/compiler/gen/tests/helpers/eval.rs @@ -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); diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index a6675effde..4676341203 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -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 diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 5a635a41bc..cc479c6a96 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -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 { diff --git a/compiler/unify/src/unify.rs b/compiler/unify/src/unify.rs index 139976b205..3649d194af 100644 --- a/compiler/unify/src/unify.rs +++ b/compiler/unify/src/unify.rs @@ -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.