Fix bug in unifying records

This was leading us to have an infinitely-recursive type, which eventually causes layout to stack-overflow

Fixes #4739
This commit is contained in:
Joshua Warner 2022-12-15 19:12:12 -08:00
parent faaa466c70
commit 174f7d5e4d
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 191 additions and 13 deletions

View file

@ -522,6 +522,41 @@ mod solve_expr {
);
}
#[test]
fn choose_correct_recursion_var_under_record() {
infer_queries!(
indoc!(
r#"
Parser : [
Specialize Parser,
Record (List {parser: Parser}),
]
printCombinatorParser : Parser -> Str
printCombinatorParser = \parser ->
when parser is
# ^^^^^^
Specialize p ->
printed = printCombinatorParser p
if Bool.false then printed else "foo"
Record fields ->
fields
|> List.map \f ->
printed = printCombinatorParser f.parser
if Bool.false then printed else "foo"
|> List.first
|> Result.withDefault ("foo")
printCombinatorParser (Record [])
"#
),
@r###"
parser : [Record (List { parser : a }), Specialize a] as a
"###
print_only_under_alias: true
);
}
// #[test]
// fn block_string_literal() {
// infer_eq(