research bug with linked list and uniqueness

This commit is contained in:
Folkert 2020-10-14 00:49:14 +02:00
parent f6106166f1
commit 2da2c25d32
4 changed files with 43 additions and 26 deletions

View file

@ -534,18 +534,21 @@ mod gen_primitives {
assert_evals_to!( assert_evals_to!(
indoc!( indoc!(
r#" r#"
LinkedList a : [ Nil, Cons a (LinkedList a) ] app LinkedListLen0 provides [ main ] imports []
nil : LinkedList Int LinkedList a : [ Nil, Cons a (LinkedList a) ]
nil = Nil
length : LinkedList a -> Int nil : LinkedList Int
length = \list -> nil = Nil
when list is
Nil -> 0 length : LinkedList a -> Int
Cons _ rest -> 1 + length rest length = \list ->
when list is
Nil -> 0
Cons _ rest -> 1 + length rest
main =
length nil length nil
"# "#
), ),

View file

@ -1,7 +1,7 @@
use roc_collections::all::{MutMap, MutSet}; use roc_collections::all::{MutMap, MutSet};
fn promote_expr_to_module(src: &str) -> String { fn promote_expr_to_module(src: &str) -> String {
let mut buffer = String::from("app Quicksort provides [ main ] imports []\n\nmain =\n"); let mut buffer = String::from("app Test provides [ main ] imports []\n\nmain =\n");
for line in src.lines() { for line in src.lines() {
// indent the body! // indent the body!
@ -282,7 +282,7 @@ macro_rules! assert_evals_to {
// parsing the source, so that there's no chance their passing // parsing the source, so that there's no chance their passing
// or failing depends on leftover state from the previous one. // 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); assert_opt_evals_to!($src, $expected, $ty, $transform, $leak);

View file

@ -3,7 +3,7 @@ use crate::exhaustive::{Ctor, Guard, RenderAs, TagId};
use crate::layout::{Builtin, Layout, LayoutCache, LayoutProblem}; use crate::layout::{Builtin, Layout, LayoutCache, LayoutProblem};
use bumpalo::collections::Vec; use bumpalo::collections::Vec;
use bumpalo::Bump; use bumpalo::Bump;
use roc_collections::all::{default_hasher, MutMap, MutSet, SendMap}; use roc_collections::all::{default_hasher, MutMap, MutSet};
use roc_module::ident::{Ident, Lowercase, TagName}; use roc_module::ident::{Ident, Lowercase, TagName};
use roc_module::low_level::LowLevel; use roc_module::low_level::LowLevel;
use roc_module::symbol::{IdentIds, ModuleId, Symbol}; use roc_module::symbol::{IdentIds, ModuleId, Symbol};

View file

@ -469,21 +469,35 @@ fn solve(
let visit_mark = young_mark.next(); let visit_mark = young_mark.next();
let final_mark = visit_mark.next(); let final_mark = visit_mark.next();
debug_assert!({ debug_assert_eq!(
next_pools {
.get(next_rank) let offenders = next_pools
.iter() .get(next_rank)
.filter(|var| { .iter()
subs.get_without_compacting(roc_types::subs::Variable::clone( .filter(|var| {
var, let current = subs.get_without_compacting(
)) roc_types::subs::Variable::clone(var),
.rank );
.into_usize()
> next_rank.into_usize() current.rank.into_usize() > next_rank.into_usize()
}) })
.count() .collect::<Vec<_>>();
== 0
}); let result = offenders.len();
if result > 0 {
dbg!(
&subs,
&offenders,
&let_con.def_types,
&let_con.def_aliases
);
}
result
},
0
);
// pop pool // pop pool
generalize(subs, young_mark, visit_mark, next_rank, next_pools); generalize(subs, young_mark, visit_mark, next_rank, next_pools);