datalog: dl-magic-query shape validator (255/255)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 44s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 44s
Bug: dl-magic-query crashed with cryptic "rest: 1 list arg" when the goal argument was a string, number, or arbitrary dict. The first thing the function does is dl-rel-name + dl-adorn-goal, both of which assume a positive-literal list shape. Fix: explicit shape check up front. A goal must be a non-empty list whose first element is a symbol. Otherwise raise with a clear diagnostic. Built-in / aggregate / negation dispatch (the fall-back to dl-query) is unchanged. 2 new magic tests cover string and bare-dict goal rejection.
This commit is contained in:
@@ -382,6 +382,11 @@
|
||||
;; (built-ins, aggregates, EDB-only relations) the seed is either
|
||||
;; non-ground or unused; fall back to dl-query.
|
||||
(cond
|
||||
((not (and (list? query-goal)
|
||||
(> (len query-goal) 0)
|
||||
(symbol? (first query-goal))))
|
||||
(error (str "dl-magic-query: goal must be a positive literal "
|
||||
"(non-empty list with a symbol head), got " query-goal)))
|
||||
((or (dl-builtin? query-goal)
|
||||
(dl-aggregate? query-goal)
|
||||
(and (dict? query-goal) (has-key? query-goal :neg)))
|
||||
|
||||
Reference in New Issue
Block a user