datalog: quoted 'atoms' tokenize as strings
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s

Quoted atoms with uppercase- or underscore-leading names were
misclassified as variables. `p('Hello World').` flowed through the
tokenizer's "atom" branch and through the parser's string->symbol,
producing a symbol named "Hello World". dl-var? inspects the first
character — "H" is uppercase, so the fact was rejected as non-ground
("expected ground literal").

Tokenizer now emits "string" for any '...' quoted form. Quoted atoms
become opaque string constants — matching how Datalog idiomatically
treats them, and avoiding a per-symbol "quoted" marker that would
have rippled through unification and dl-var?. The trade-off is that
'a' and a are no longer the same value (string vs symbol); for
Datalog this is the safer default.

Updated the existing "quoted atom" tokenize test, added a regression
case for an uppercase-named quoted atom, and a parse-level test that
verifies the AST. Conformance 269/269.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 08:39:24 +00:00
parent 917ffe5ccc
commit 7a94a47e26
6 changed files with 49 additions and 14 deletions

View File

@@ -15,7 +15,7 @@ for rose-ash data (e.g. federation graph, content relationships).
## Status (rolling)
`bash lib/datalog/conformance.sh`**267/267 across 11 suites**
`bash lib/datalog/conformance.sh`**269/269 across 11 suites**
(tokenize, parse, unify, eval, builtins, semi_naive, negation, aggregates,
api, magic, demo). Source is ~3100 LOC, tests ~2900 LOC, public API
documented in `lib/datalog/datalog.sx`.
@@ -320,6 +320,18 @@ large graphs.
_Newest first._
- 2026-05-11 — Quoted atoms with uppercase-or-underscore-leading
names were misclassified as variables. `p('Hello World').` ran
through the tokenizer's `"atom"` branch and through the parser's
`string->symbol`, producing a symbol named "Hello World". dl-var?
checks the first character — "H" is uppercase, so the fact was
rejected as non-ground. Fix: tokenizer emits `"string"` for any
`'...'` quoted form, so quoted atoms become opaque string constants
(matching how Datalog idiomatically treats them — the alternative
was a per-symbol "quoted" marker which would have rippled through
unification and dl-var?). Updated the existing tokenize test and
added one for `'Hello'`; also added a parse-level regression. 269/269.
- 2026-05-11 — Type-mixed comparisons were silently inconsistent:
`<(X, 5)` with `X` bound to a string returned `()` (no result, no
error), while `X` bound to a symbol raised "Expected number, got