Skip to content

Closure-adaptor run check reads a table column for a call outside its loop #8012

Closed

Description

@EffortlessSteven

Gap. constant_table_column(fn_text, name) returns a constant-row table's column for name without checking that the asserted call sits inside that table's loop body. When the test's only binding of name is the loop pattern, a call after the loop that names name reads some other item, for example a module-level const x. The loop's rows are then credited as that call's values.

Where.

  • Pin a pure &&/|| owner tail on a call that runs every operand (RIPR-SPEC-0197) #7972 fixed this for the RIPR-SPEC-0197 short-circuit run check. It added constant_table_column_around(fn_text, name, at), which also requires the loop body to hold the call's offset.
  • owner_pin/closure_adaptor.rs (RIPR-SPEC-0265 pinned_call_runs_closure, around argument_sequences) still calls constant_table_column. It can therefore credit a closure run from rows the asserted call never sees.

Repro shape (adaptor variant, not yet run):

#[allow(non_upper_case_globals)] const x: Option<i32> = None;
#[test] fn t() {
    for (x, want) in [(Some(2), 6)] { let _ = (x, want); }
    assert_eq!(f(x), 0); // x is the const None; the closure never runs
}

Fix. Switch the closure-adaptor lookup to constant_table_column_around, passing the assertion line's call offset, as short_circuit::call_offset does. Add an off-loop regression test.

Goal it hurts: trustworthy verdicts (false credit). Owner: the owner-pin / RIPR-SPEC-0265 lane.

Found by CodeRabbit on #7972.

Activity

  1. added 2 commits that reference this issue on Oct 18, 2026
  2. EffortlessSteven commented on Oct 18, 2026

    @EffortlessSteven
    MemberAuthor

    Fixed by #8560 (squash 6fbe7b4). argument_sequences now uses constant_table_column_around with the call offset and refuses when the site is absent or ambiguous, so a table loop that does not contain the call no longer credits the pin. Tests: off-loop (fails on old code), in-loop positive, and twice-occurring site. Independent exact-head review: no blocking findings.


    Generated by Claude Code

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions