Skip to content

fix(rt): repair closure callee setup for iter-eq repro#957

Merged
Stevengre merged 3 commits intomasterfrom
jh/fix-closure-type-call-setup
Mar 9, 2026
Merged

fix(rt): repair closure callee setup for iter-eq repro#957
Stevengre merged 3 commits intomasterfrom
jh/fix-closure-type-call-setup

Conversation

@Stevengre
Copy link
Contributor

@Stevengre Stevengre commented Feb 28, 2026

Summary

  • adds iter-eq-copied-take-dereftruncate as a regression
  • fixes setupCalleeClosure2 by initializing callee _1 with the closure env before tuple unpacking
  • removes temporary show tracking after the repro reaches #EndProgram

Why This Fix

  • Red commit frontier: after 1947 steps the new repro stopped at:
    • #traverseProjection(toLocal(1), thunk(operandCopy(place(... local: local(1) ...))))
  • Root cause: setupCalleeClosure2 reserved NEWLOCALS and unpacked the tuple argument into _2.., but never wrote the closure receiver/env into _1. The std closure body later dereferenced local(1), so execution walked a bad projection path instead of the closure env.
  • Fix: write #incrementRef(getValue(LOCALS, CLOSURE)) into local(1) before #setTupleArgs(2, ...).
  • Effect: the same repro moves from the stuck 1947-step leaf to #EndProgram after 5601 steps. The cleanup commit then deletes only the temporary show artifact.

automergerpr-permission-manager bot pushed a commit to runtimeverification/stable-mir-json that referenced this pull request Mar 2, 2026
#129)

### Summary
- In `TyCollector::visit_ty` (`src/printer.rs`), after successful
closure instance traversal, record closure `Ty` metadata in `types`.
- Update integration golden files
(`tests/integration/programs/*.smir.json.expected`) to match emitted
closure `FunType` metadata.
- Keep `Makefile` integration path as
`TESTDIR=tests/integration/programs` to keep closure fixture output
paths stable.

### Context
In the closure arm of `TyCollector::visit_ty`, the code resolved and
visited the closure instance but returned without inserting the closure
`Ty` into `types`. Other type families were inserted; closures were the
exception.

This made downstream closure type lookup incomplete (notably for kmir
proof paths that consume exported type metadata). Recording closure `Ty`
closes that gap.

Related split: static/vtable alloc fallback changes were moved out to
[stable-mir-json#131](#131)
so this PR stays focused on closure metadata.

Dependency context: this PR is depended on by
[mir-semantics#957](runtimeverification/mir-semantics#957).
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch 2 times, most recently from 085f266 to cf54fdd Compare March 3, 2026 09:59
@Stevengre Stevengre changed the base branch from master to codex/base-pr957-red March 3, 2026 10:00
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch from 9ffa29f to 79f90e4 Compare March 4, 2026 03:17
@Stevengre Stevengre changed the base branch from codex/base-pr957-red to codex/base-pr957-pr955-pr956 March 4, 2026 03:18
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch 2 times, most recently from 761dbc0 to 1986fca Compare March 4, 2026 05:04
@Stevengre Stevengre self-assigned this Mar 4, 2026
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch from 24094d5 to 9605315 Compare March 5, 2026 06:38
@Stevengre Stevengre changed the base branch from codex/base-pr957-pr955-pr956 to codex/base-pr957-master-952-955 March 5, 2026 06:39
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch from 9605315 to 372ae6f Compare March 5, 2026 12:46
@Stevengre Stevengre deleted the branch master March 9, 2026 02:20
@Stevengre Stevengre closed this Mar 9, 2026
@Stevengre Stevengre reopened this Mar 9, 2026
@Stevengre Stevengre changed the base branch from codex/base-pr957-master-952-955 to master March 9, 2026 02:24
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch from 372ae6f to ba3fc56 Compare March 9, 2026 05:56
@Stevengre Stevengre changed the title fix(rt): closure type metadata decode + setupCalleeClosure3 fix(rt): repair closure callee setup for iter-eq repro Mar 9, 2026
@Stevengre Stevengre force-pushed the jh/fix-closure-type-call-setup branch from ba3fc56 to 1da9552 Compare March 9, 2026 10:37
@Stevengre Stevengre marked this pull request as ready for review March 9, 2026 12:03
@Stevengre Stevengre requested review from dkcumming and mariaKt March 9, 2026 12:03
Copy link
Collaborator

@dkcumming dkcumming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice looks good!

@Stevengre Stevengre merged commit c5be649 into master Mar 9, 2026
7 checks passed
@Stevengre Stevengre deleted the jh/fix-closure-type-call-setup branch March 9, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants