mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-31 17:17:26 +00:00
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:
parent
faaa466c70
commit
174f7d5e4d
5 changed files with 191 additions and 13 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue