Skip to content

s2/names: whole-program declaration checks (NAMES + DECL) - #13

Merged
vic merged 2 commits into
mainfrom
s2-names
Nov 9, 2026
Merged

vic merged 2 commits into
mainfrom
s2-names

Conversation

@vic

@vic vic commented Nov 9, 2026

Copy link
Copy Markdown
Owner

P4 NAMES + DECL: whole-program declaration checks as one Datalog solve (s2/names.srs, module Names).

  • Facts: each declaration by namespace with its own id (calls: defs, enum cases; types: enums, protocols, handlers, builtins); every call or name a body uses that no local binds; every type named outside the [] binders in scope; protocol states, start, transitions, drop op; handler fns and arities.
  • Clashes derived by rules: Dup (both declarations), Unknown, NoType, BadState, NoDrop, NoProto, NoInit, NoOp, BadArity (op params + 1).
  • Readback is typed: any other tuple shape is RulesBad.

Tests: tests/s2/names has a passing program (generic enum, locals, cases, a match, a handle) and one failing program per clash kind. Seven one-line mutants each change the output.

Also in this PR: tests/s2/bmap checks build-from-sorted over 1..20000 instead of 1..100000, because the test ran near the 1 s per-test cap under load. Local tests/run.sh: 183 ok, 0 FAIL.

vic added 2 commits November 8, 2026 22:45
…0000

The test ran close to the 1 s cap per s2 test under load. Sizes 0..40 still cover every group remainder
at each level; the 100k fill and seq workloads (the imap.out lines) stay.
Names.facts walks the declarations once: each declaration by namespace (calls: defs and enum cases;
types: enums, protocols, handlers, the builtins) with its own id, every call and name a body uses that
no local binds (params, {} binders, val, var, handle, pattern binders), every type named outside the []
binders in scope, protocol states, start, transitions and drop op, handler fns with their arities. One
D.solve with Names.rules derives the clashes: Dup (both declarations), Unknown, NoType, BadState,
NoDrop, NoProto, NoInit, NoOp, BadArity (op params + 1). The readback is typed: another tuple shape is
RulesBad.

tests/s2/names: a program that passes (a generic enum, locals, cases, a match, a handle), then one
program per clash kind. Mutants: dup without distinct ids, locals ignored, [] binders ignored, val not
binding, pattern binders not binding, arity unchecked, arity without self: each changes the output.
@vic
vic merged commit aea3e51 into main Nov 9, 2026
3 checks passed
@vic
vic deleted the s2-names branch November 9, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant