Skip to content

Verifier does not obligate @Nat->@Int widening in a nested closure's return (codegen over-guards soundly; reporting-completeness gap) #985

Description

@aallan

Summary

A closure defined inside another closure's body that widens @Nat into an @Int return is runtime-guarded by codegen (_compile_lifted_closure lifts and guards it) but not obligated by the verifier — the verifier's AnonFn widening handler is deliberately shallow: it does not recurse into a closure body, because translating there against the outer slot environment could mis-resolve a closure parameter and prove a false Tier-1.

Consequence: codegen over-guards (sound — an extra runtime trap on a real widening, never a false proof), but vera verify under-reports: the obligation stream carries no entry for the nested closure's widening, so the summary's Tier-3 count omits a runtime check that codegen actually emits, and the strict verifier↔codegen differential does not hold for the nested shape.

A reporting-completeness limitation, not a soundness hole — same family as #779 (obligation walkers stopping at fresh-scope bodies: closures / quantifiers / handler clauses).

Found during the #820 per-component metadata work (PR pending), which added the single-level closure argument/return/capture obligations and guards; the nested case is the residual.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlimitationKnown compilation limitationverificationContract verification system

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions