Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support opens_invariants with concrete sets #93

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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!
"###)
}