Skip to content

Phase 4.3 — Conformance: conditional move across branches is rejected #37

Description

@whoisclebs

Parent

Part of #6 (Phase 4: Implement ownership and move semantics).

Background

When a value is moved inside one branch of an if/else but not the other, the post-if state is ambiguous — the compiler cannot guarantee whether the value is owned or consumed. This inconsistency must be rejected: the binding must be consistently moved in all branches or in none. The dataflow analysis merges states across branches and flags the discrepancy.

Spec reference: docs/design/spec.md §3 · Lint: use-after-move · Crate: paco-borrow

What already exists

  • compiler/paco-borrow/src/lib.rs — branch-merge logic that requires consistent move state across arms.
  • compiler/paco-test-harness/src/lib.rs — golden test harness.

Scope

  • Create tests/conformance/phase_04/conditional_move/input.paco — a value moved in the then-branch of an if but used unconditionally after the if.
  • Create tests/conformance/phase_04/conditional_move/expected.stderr with the diagnostic on the post-if use.
  • Create tests/conformance/phase_04/conditional_move/flags.toml with kind = "fail" and feature_min = 4.

Acceptance Criteria

  • Compilation fails with a diagnostic about inconsistent move state.
  • The diagnostic span points at the post-if use of the potentially-moved variable.
  • expected.stderr matches actual stderr byte-for-byte.
  • All previously passing conformance tests remain green.

Key files

  • tests/conformance/phase_04/conditional_move/ — new test directory
  • compiler/paco-borrow/src/lib.rs — branch-merge move analysis
  • compiler/paco-driver/tests/conformance.rs — conformance runner

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/analysisType system, trait solver, borrow checker, pattern matchingenhancementNew feature or requestphase/4Phase 4: ownership and move semanticsstatus/readyAll dependencies met — ready to implement

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions