datalog: dl-walk handles circular substitutions without infinite loop (257/257)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s

Bug: dl-walk would infinite-loop on a circular substitution
(e.g. A→B and B→A simultaneously). The walk endlessly chased
the cycle. This couldn't be produced through dl-unify (which has
cycle-safe behavior via existing bindings), but raw dl-bind calls
or external manipulation of the subst dict could create it.

Fix: dl-walk now threads a visited-names list through the
recursion. If a variable name is already in the list, the walk
stops and returns the current term unchanged. Normal chained
walks are unaffected (A→B→C→42 still resolves to 42).

1 new unify test verifies circular substitutions don't hang.
This commit is contained in:
2026-05-11 07:20:20 +00:00
parent a9e4eea334
commit 9a16f27075
4 changed files with 32 additions and 11 deletions

View File

@@ -1,12 +1,12 @@
# datalog scoreboard
**256 / 256 passing** (0 failure(s)).
**257 / 257 passing** (0 failure(s)).
| Suite | Passed | Total | Status |
|-------|--------|-------|--------|
| tokenize | 30 | 30 | ok |
| parse | 22 | 22 | ok |
| unify | 28 | 28 | ok |
| unify | 29 | 29 | ok |
| eval | 38 | 38 | ok |
| builtins | 23 | 23 | ok |
| semi_naive | 8 | 8 | ok |