datalog: aggregate arg validators (259/259)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s

Bug: dl-eval-aggregate accepted non-variable agg-vars and non-
literal goals silently, producing weird/incorrect counts:
- `count(N, 5, p(X))` would compute count over the single
  constant 5 (always 1), ignoring p entirely.
- `count(N, X, 42)` would crash with "unknown body-literal
  shape" at saturation time rather than at rule-add time.

Fix: dl-eval-aggregate now validates up front that the second
arg is a variable (the value to aggregate) and the third arg is
a positive literal (the goal). Errors are descriptive and
include the offending argument.

2 new aggregate tests.
This commit is contained in:
2026-05-11 07:26:48 +00:00
parent 9a16f27075
commit dcae125955
4 changed files with 44 additions and 24 deletions

View File

@@ -1,8 +1,8 @@
{
"lang": "datalog",
"total_passed": 257,
"total_passed": 259,
"total_failed": 0,
"total": 257,
"total": 259,
"suites": [
{"name":"tokenize","passed":30,"failed":0,"total":30},
{"name":"parse","passed":22,"failed":0,"total":22},
@@ -11,10 +11,10 @@
{"name":"builtins","passed":23,"failed":0,"total":23},
{"name":"semi_naive","passed":8,"failed":0,"total":8},
{"name":"negation","passed":10,"failed":0,"total":10},
{"name":"aggregates","passed":20,"failed":0,"total":20},
{"name":"aggregates","passed":22,"failed":0,"total":22},
{"name":"api","passed":20,"failed":0,"total":20},
{"name":"magic","passed":36,"failed":0,"total":36},
{"name":"demo","passed":21,"failed":0,"total":21}
],
"generated": "2026-05-11T07:20:07+00:00"
"generated": "2026-05-11T07:26:33+00:00"
}