Skip to content

Verifier+codegen: refined-predicate narrowing into an apply_fn closure formal is not obligated/guarded (false Tier-1) #1024

Description

@aallan

Summary

The refined-predicate narrowing dual of #1017 at the apply_fn argument boundary. #1017 added the @Int -> @Nat narrowing obligation + guard, which covers the >= 0 base invariant of a refinement-over-@Nat formal. But the full refinement predicate (e.g. > 0) is still not checked at apply_fn: passing a value that satisfies >= 0 yet violates the predicate verifies clean and runs without trapping.

The generic call-argument path obligates this via _refined_binding_target + _check_refined_binding_obligation (verifier) and the corresponding runtime refinement guard (codegen); the apply_fn branch has neither refined arm — only the @Nat (#1017) and @Nat -> @Int widening (#820) arms.

Reproduction

type Pos = { @Nat | @Nat.0 > 0 };
type PosToInt = fn(Pos -> Int) effects(pure);
private fn f(@PosToInt -> @Int) requires(true) ensures(true) effects(pure)
{ apply_fn(@PosToInt.0, 0) }

vera verifyclean (2 verified, Tier 1). Should reject: 0 narrows into { @Nat | @Nat.0 > 0 } but 0 > 0 is false. A named-call take(0) with the same @Pos formal correctly reports the refinement violation (Value narrowing into a refined call argument … may violate the refinement predicate @Nat.0 >= 0 && @Nat.0 > 0).

At runtime, apply_fn(clo_pos_formal, 0) returns the closure body value silently rather than trapping — the #1017 nat guard's >= 0 passes 0, and the strict > 0 is unguarded.

Root cause (located)

Provenance

Found during the #1017 completeness sweep (the refined dual of the @Nat narrowing). #1017 covers the >= 0 base — a negative value now correctly traps (run(-5)); this issue is the residual strict-predicate gap (run(0) on > 0). Grouped with the refined-binding family (#746) and the apply_fn narrowing family (#1017 / #820).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions