mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +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
|
@ -1530,6 +1530,34 @@ fn encode_derived_record() {
|
|||
)
|
||||
}
|
||||
|
||||
#[mono_test(no_check)]
|
||||
fn choose_correct_recursion_var_under_record() {
|
||||
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 [])
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn tail_call_elimination() {
|
||||
indoc!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue