Skip to content

Merge in latest master#973

Merged
mariaKt merged 3 commits intofeature/p-tokenfrom
master
Mar 4, 2026
Merged

Merge in latest master#973
mariaKt merged 3 commits intofeature/p-tokenfrom
master

Conversation

@dkcumming
Copy link
Collaborator

  • fix(rt): handle fun-type closure env refs in callee setup 956
  • fix(decode): accept signed enum tag scalars in _extract_tag 954
  • Added check for FunType in `setupCalleeClosure 969

Stevengre and others added 3 commits March 4, 2026 15:18
- Extend closure callee setup (`setupCalleeClosure2`) to accept
closure-env references whose pointee resolves to `typeInfoFunType` (in
addition to `typeInfoVoidType`).
- Add `isFunType(TypeInfo)` helper predicate used by that guard.
- In the fix commit, refresh `closure_access_struct-fail.main.expected`
to show the behavior change from stuck frontier to terminal
`#EndProgram`.
- Cleanup after fix:
  - rename `closure_access_struct-fail.rs` -> `closure_access_struct.rs`
  - remove `show/closure_access_struct-fail.main.expected`
  - remove this case from `PROVE_RS_SHOW_SPECS`
## Summary

- Relax `_extract_tag` to accept both signed and unsigned `PrimitiveInt`
tag metadata (`signed=_`).
- Keep discriminant decoding based on raw tag bits (`int.from_bytes(...,
signed=False)`), which is what variant dispatch needs.
- Add a decode fixture for signed-tag metadata
(`enum-3-variants-0-fields-signed-tag`).
- Update the prove-rs case to a passing case and refresh its `show`
snapshot.

## Problem (concrete case)

This PR is motivated by:


`kmir/src/tests/integration/data/prove-rs/transmute-u8-to-enum-changed-discriminant-signed.rs`

```rust
#[repr(i8)]
enum AccountState {
    Uninitialized = 0,
    Initialized = 1,
    Frozen = -1,
}

// main checks both byte-level and signed views of the same discriminant bits:
// 255 maps to Frozen in the u8 path
// -1 maps to Frozen in the i8 path
```

For this enum layout, the tag scalar metadata can be `signed=true` (I8),
even though the stored discriminant bytes are still valid raw bytes for
dispatch.

## Red (before this fix)

`_extract_tag` only matched `PrimitiveInt(..., signed=False)`. When
metadata was signed, decode failed with:

```text
ValueError: Unsupported tag: Initialized(value=PrimitiveInt(length=I8, signed=True), ...)
```

That blocked the signed-discriminant path in proving.

## Green (after this fix)

- `_extract_tag` now accepts either signedness metadata.
- The same bytes are decoded as unsigned raw bits for dispatch.
- The concrete program above now proves in integration tests:
- input case is now
`transmute-u8-to-enum-changed-discriminant-signed.rs`
- expected proof snapshot is
`show/transmute-u8-to-enum-changed-discriminant-signed.main.expected`
  - terminal `#EndProgram` is reached for `main`

## Why this is the right scope

This change fixes tag extraction compatibility for signed discriminant
metadata without changing enum dispatch semantics beyond that path. It
is covered by both:

- decode-value fixture (`enum-3-variants-0-fields-signed-tag`) and
- end-to-end prove-rs integration snapshot for the concrete Rust program
above.

---------

Co-authored-by: automergerpr-permission-manager[bot] <190534181+automergerpr-permission-manager[bot]@users.noreply.github.com>
#956 added handles `FunType` for closures instead of `VoidType` for that
come from [stable mir json
129](runtimeverification/stable-mir-json#129)
for `setupCalleeClosure2`. This PR adds the same thing to
`setupCalleeClosure`. (Fixes regressed proofs for P-Token)

- Added explicit `FnOnce` test `closure_fnonce_tuple_arg.rs`
- Fixed `and_then_closure.rs`
@mariaKt mariaKt merged commit c1198df into feature/p-token Mar 4, 2026
8 checks passed
dkcumming added a commit to runtimeverification/solana-token that referenced this pull request Mar 10, 2026
- fix(rt): handle fun-type closure env refs in callee setup
[956](runtimeverification/mir-semantics#956)
- fix(decode): accept signed enum tag scalars in _extract_tag
[954](runtimeverification/mir-semantics#954)
- Added check for FunType in setupCalleeClosure
[969](runtimeverification/mir-semantics#969)
- Merge in latest master
[973](runtimeverification/mir-semantics#973)
- fix(kompile): map linked NormalSym functions to monoItemFn(noBody)
[953](runtimeverification/mir-semantics#953)
- fix(rt): generalize direct-tag enum decoding to any variant count and
discriminant
[955](runtimeverification/mir-semantics#955)
- fix(spl-token): encode multisig signers as pubkey aggregates
[958](runtimeverification/mir-semantics#958)
- fix(rt): closure aggregate + #setTupleArgs fallback
[952](runtimeverification/mir-semantics#952)
- fix(rt): bug fix for castKindPtrToPtr
[974](runtimeverification/mir-semantics#974)
- fix(rt): repair closure callee setup for iter-eq repro
[957](runtimeverification/mir-semantics#957)
- Change the number of signers from 11 to 3
[982](runtimeverification/mir-semantics#982)
- Merging latest master into feature/p-token
[981](runtimeverification/mir-semantics#981)
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.

3 participants