Skip to content

Annotate injections - #160

Merged
simonspies merged 2 commits into
mainfrom
annotate-injections
Aug 3, 2026
Merged

Annotate injections#160
simonspies merged 2 commits into
mainfrom
annotate-injections

Conversation

@simonspies

Copy link
Copy Markdown
Owner

Two changes to how injections are handled, in preparation for typing a constructor at the name it was declared under.

Store the sum type on the node. Typed.Expr.inj carries the sum it injects into, instead of the verifier reconstructing sum(empty, …, payloadTy, …, empty) from the payload's type. The verifier checks the annotation with injComponents? — the sum must have arity components and its tag-th must be the payload's type — so nothing downstream has to trust the elaborator. compileInj_correct reads the components off that check rather than rebuilding them.

Carry the declaring type name from the frontend. Untyped.Expr.inj gains the TypeName its constructor was declared under. The frontend resolves the constructor against its declaration anyway, so the name is already at hand; the elaboration environment's constructor table becomes a CtorInfo record (tag, arity, owner, payload) instead of a positional triple. Typing ignores the field for now — it is what lets a later commit type an injection at its name, with the declaration's parameters solved from the use site, so [] no longer needs a sum reconstructed around it.

Build and full testsuite green.

🤖 Generated with Claude Code

… it, instead of reconstructing a sparse sum from the payload's type.
…d into the untyped injection, resolving a constructor to a named record instead of a positional triple.
@simonspies
simonspies merged commit 9142708 into main Aug 3, 2026
4 checks passed
@simonspies
simonspies deleted the annotate-injections branch August 3, 2026 19:07
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