datalog: comparison ops require same-type operands
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s

Type-mixed comparisons were silently inconsistent:

  <("hello", 5)  =>  no result, no error  (silent false)
  <(a, 5)        =>  raises "Expected number, got symbol"

Both should fail loudly with a comprehensible message. Added
dl-compare-typeok?: <, <=, >, >= now require both operands to share
a primitive type (both numbers or both strings) and raise a clear
"comparison <op> requires same-type operands" error otherwise.

`!=` is exempted because it's the polymorphic inequality test
built on dl-tuple-equal? — cross-type pairs are legitimately unequal
and the existing semantics for that case match user intuition.

2 new regression tests; conformance 267/267.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 08:07:40 +00:00
parent ba60db2eef
commit 917ffe5ccc
5 changed files with 58 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
# datalog scoreboard
**265 / 265 passing** (0 failure(s)).
**267 / 267 passing** (0 failure(s)).
| Suite | Passed | Total | Status |
|-------|--------|-------|--------|
@@ -8,7 +8,7 @@
| parse | 22 | 22 | ok |
| unify | 29 | 29 | ok |
| eval | 40 | 40 | ok |
| builtins | 24 | 24 | ok |
| builtins | 26 | 26 | ok |
| semi_naive | 8 | 8 | ok |
| negation | 10 | 10 | ok |
| aggregates | 23 | 23 | ok |