Skip to content

Commit 7258cfb

Browse files
authored
Added check for FunType in setupCalleeClosure (#969)
#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`
1 parent 431a484 commit 7258cfb

6 files changed

Lines changed: 13 additions & 19 deletions

File tree

kmir/src/kmir/kdist/mir-semantics/kmir.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,10 @@ Therefore a heuristics is used here:
548548
andBool isTypedValue(LOCALS[TUPLE])
549549
andBool isTupleType(lookupTy(tyOfLocal({LOCALS[TUPLE]}:>TypedLocal)))
550550
andBool isTypedLocal(LOCALS[CLOSURE])
551-
andBool typeInfoVoidType ==K lookupTy(tyOfLocal({LOCALS[CLOSURE]}:>TypedLocal))
552-
// either the closure ref type is missing from type table
551+
andBool (
552+
typeInfoVoidType ==K lookupTy(tyOfLocal({LOCALS[CLOSURE]}:>TypedLocal))
553+
orBool isFunType(lookupTy(tyOfLocal({LOCALS[CLOSURE]}:>TypedLocal)))
554+
)
553555
[priority(40), preserves-definedness]
554556
555557
rule [setupCalleeClosure2]: <k> #setUpCalleeData(

kmir/src/tests/integration/data/crate-tests/two-crate-bin/crate2::main.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
┌─ 1 (root, init)
33
│ #execTerminator ( terminator ( ... kind: terminatorKindCall ( ... func: operandC
44
5-
│ (740 steps)
5+
│ (737 steps)
66
├─ 3 (terminal)
77
│ #EndProgram ~> .K
88

kmir/src/tests/integration/data/prove-rs/and_then_closure-fail.rs renamed to kmir/src/tests/integration/data/prove-rs/and_then_closure.rs

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn apply<F: FnOnce(u8, u8) -> u8>(f: F, a: u8, b: u8) -> u8 {
2+
f(a, b)
3+
}
4+
5+
fn main() {
6+
let result = apply(|x, y| x + y, 10, 32);
7+
assert_eq!(result, 42);
8+
}

kmir/src/tests/integration/data/prove-rs/show/and_then_closure-fail.main.expected

Lines changed: 0 additions & 15 deletions
This file was deleted.

kmir/src/tests/integration/test_integration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
'test_offset_from-fail',
6363
'ref-ptr-cast-elem-fail',
6464
'ref-ptr-cast-elem-offset-fail',
65-
'and_then_closure-fail',
6665
]
6766

6867

0 commit comments

Comments
 (0)