Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kmir/src/kmir/kdist/mir-semantics/kmir.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ Therefore a heuristics is used here:
// unpack tuple and set arguments individually
rule <k> #setTupleArgs(IDX, Aggregate(variantIdx(0), ARGS)) => #setTupleArgs(IDX, ARGS) ... </k>

rule <k> #setTupleArgs(IDX, VAL:Value)
=> #setTupleArgs(IDX, ListItem(VAL))
...
</k> [owise]

rule <k> #setTupleArgs(_, .List ) => .K ... </k>

rule <k> #setTupleArgs(IDX, ListItem(VAL) REST:List)
Expand Down
6 changes: 6 additions & 0 deletions kmir/src/kmir/kdist/mir-semantics/rt/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,12 @@ Literal arrays are also built using this RValue.
...
</k>

rule <k> ARGS:List ~> #mkAggregate(aggregateKindClosure(_DEF, _TY_ARGS))
=>
Aggregate(variantIdx(0), ARGS)
...
</k>


// #readOperands accumulates a list of `TypedLocal` values from operands
syntax KItem ::= #readOperands ( Operands )
Expand Down
11 changes: 11 additions & 0 deletions kmir/src/tests/integration/data/prove-rs/closure-staged.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn apply<F: FnOnce(u8) -> u8>(f: F, v: u8) -> u8 {
f(v)
}

fn main() {
let delta: u8 = 1u8;
let _captured = |x: u8| x + delta;

let f = |x: u8| x + 1u8;
assert_eq!(apply(f, 41u8), 42u8);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great example. If you would be open to it in the future it would be nice to use git rebase -i to have the inclusion of the test as the first commit with the expected output failing clearly, then the inclusion of the fix in a following commit, then the update of the test from failing to to passing. It isn't a bit deal but it makes it nice to see the commit history as a story solving the problem. I think #919 is a good example of this.