Skip to content

validate-all: the ownership validator never judged a read of a local on a path that never initialized it (a match's no-arm join) #1883

Closed

Description

@ehartford

Tool defect

check --validate-all said ok over a value-position match whose no-arm path fell through to the join and returned the never-written result temp (#1860's sealed-trait match on *s: print("start"), then the process ended silently with exit 0). The ownership validator judged drops of a place on a path that never initialized it (#729, #1559) but never a read: _0 = copy _4 at the join, with _4 Init on the arm path and Uninit on the fallthrough (Maybe), passed.

Rule

A copy or move operand of a whole local whose drop-state at that statement is Maybe or MaybeGarbage (some reaching path never initialized it) is an error: "read of _N reaches a path that never initialized it (Maybe)". Uninit is not judged: StorageDead resets a local to Uninit and the lowering moves a block's tail local out after its scope's StorageDead by contract (_23 = move _27 after StorageDead(_27); materialize_tail_field_move).

With the rule in place, every value-position match tripped it: lower_match gave the last arm's failure edge the join block (MirLower.w:11373) even when Sema had proved the match exhaustive. That edge is now an unreachable block (Sema records the matches it proved exhaustive in exhaustive_matches; MIR consumes the fact).

Fail-before: test/internals/mir_uninit_read_test.w (a planted body: a switch whose one edge writes the local and the other does not, then a read at the join) fails against the validator at f9d0dfc4 and passes with the rule.

"A tool that stayed silent is a bug." Found while fixing #1860.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. added 2 commits that reference this issue on Sep 29, 2026
    50217d6
    ca52db5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions