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:
Ayaz Hafiz 2022-05-10 16:02:10 -04:00
parent 17d8545510
commit 710a10a29c
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
17 changed files with 261 additions and 49 deletions

View file

@ -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?
}