mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Check for invalid cycles after type solving recursive defs
Disallow cycles that pass through a non-function value. Since we evaluate eagerly, having one such cycle means there is at least one path in the program that (likely) has unbounded recursion. Of course we can't be certain (halting problem), but it's very likely, and avoids stuff like #1926. Also, mono (as it's done today) won't work if things in a cycle aren't functions. Closes #1926
This commit is contained in:
parent
17d8545510
commit
710a10a29c
17 changed files with 261 additions and 49 deletions
|
@ -4238,7 +4238,7 @@ fn build_pending_specializations<'a>(
|
|||
&exposed_to_host.values,
|
||||
false,
|
||||
),
|
||||
DeclareRec(defs) => {
|
||||
DeclareRec(defs, cycle_mark) if !cycle_mark.is_illegal(mono_env.subs) => {
|
||||
for def in defs {
|
||||
add_def_to_module(
|
||||
&mut layout_cache,
|
||||
|
@ -4251,7 +4251,7 @@ fn build_pending_specializations<'a>(
|
|||
)
|
||||
}
|
||||
}
|
||||
InvalidCycle(_entries) => {
|
||||
InvalidCycle(_) | DeclareRec(..) => {
|
||||
// do nothing?
|
||||
// this may mean the loc_symbols are not defined during codegen; is that a problem?
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue