Skip to content

Commit

Permalink
Support opens_invariants with concrete sets
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybosamiya-ms committed Sep 23, 2024
1 parent 20cabe1 commit 0ef7f8d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Support parsing `opens_invariants` with specific concrete sets

# v0.4.1

* Minor fix to prevent panic on formatting files containing unbalanced parentheses in strings/chars/...
Expand Down
1 change: 1 addition & 0 deletions src/verus.pest
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,7 @@ unwind_clause = {
opens_invariants_mode = {
any_str
| none_str
| lbracket_str ~ comma_delimited_exprs? ~ rbracket_str
}

opens_invariants_clause = {
Expand Down
38 changes: 38 additions & 0 deletions tests/verus-consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2473,3 +2473,41 @@ fn fff() {
} // verus!
"###);
}

#[test]
fn verus_support_opens_invariants() {
// Regression test for https://github.com/verus-lang/verusfmt/issues/91
let file = r#"
verus! {
proof fn a() opens_invariants none {}
proof fn f() opens_invariants [ 123u8 ] {}
proof fn g() opens_invariants [ 123u8, 456u8 ] {}
proof fn z() opens_invariants any {}
}
"#;
assert_snapshot!(parse_and_format(file).unwrap(), @r###"
verus! {
proof fn a()
opens_invariants none
{
}
proof fn f()
opens_invariants [123u8]
{
}
proof fn g()
opens_invariants [123u8, 456u8]
{
}
proof fn z()
opens_invariants any
{
}
} // verus!
"###)
}

0 comments on commit 0ef7f8d

Please sign in to comment.