Skip to content

--explain-slots is signature-only; suggest extending into match arms / W001 holes #558

Description

@yansircc

Summary

vera check --explain-slots <file> prints a slot-resolution table per function signature but not per arm body. This makes it useful for the case it documents in SKILL.md ("a function with multiple parameters of the same type") and unhelpful for the case where De Bruijn ordering bugs actually concentrate: deep inside a match arm, after a few let bindings, where the slot stack has grown by 3–5 levels and the agent is recursing into an ADT.

Concrete workflow gap

In a structural-recursion function like the substitution operator (separate companion docs issue), the position-of-error is:

App(@Term, @Term) -> {
  let @Term = ...;
  let @Term = ...;
  match @Term.1 {
    Abs(@Term) -> {
      let @Term = subst(0, @Term.???, @Term.???);   -- <-- here
      ...
    }
  }
}

By this point in the function the agent needs to know the resolved index of every named binding. --explain-slots cannot help — its output stops at the signature. The agent's options are:

  1. Manually trace pattern-push-and-let across 5 levels of nesting.
  2. Write the program, run it, dump intermediate state via IO.print(show(...)), binary-search the buggy index.

Option 2 is what I ended up doing. It works, but it's the workflow Vera positions itself against — agents bouncing off compiler/runtime feedback to reconstruct what they could have asked the tooling.

Suggested enhancement

Three concrete options, in increasing implementation cost:

(a) Slot tables in error context. When vera check reports E130 (unresolved slot), include the slot table at the position of the error, not just the function signature. This piggybacks on existing diagnostics infrastructure.

(b) --explain-slots-at <line>:<col>. A flag that prints the resolved slot environment at a specific source position, no error required. Lets an agent ask "what's in scope here?" before writing the expression.

(c) Slot table inside the ? typed-hole warning. W001 already lists "Available bindings". Extending it to print each binding's resolved @T.n would turn typed holes into the canonical "what slots can I use right now" probe — and SKILL.md already markets typed holes as the cheap way to figure out shape.

(c) is probably the highest leverage per LOC: holes already exist, the W001 diagnostic already enumerates context, and typed holes are the recommended workflow for incremental construction.

Why it matters

The companion documentation issue (match-arm shadow semantics) is essentially a cascade of this missing tool — when slot semantics in match arms are under-documented, the diagnostic that would substitute for documentation (showing the actual resolved indices at each position) is also missing. Together they make the slot system a "must run experiments to understand" feature rather than a "compiler tells me what to write" feature. Closing either issue alone helps; closing both makes the slot system live up to the agent-friendly framing.

Environment

  • Vera v0.0.127.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttoolingIssue around tooling built for the language (e.g. package managers, IDE plug-ins)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions