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 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Improved handling of comments around clauses/stanzas
- Each comment now maintains loyalty to the clause the user picked it to stay with, rather than automatically migrating to the previous clause in the presence of `assert ... by { ... }`-style constructs
* Support parsing for const generic literals
* Support parsing `opens_invariants` with specific concrete sets

# v0.4.1

Expand Down
1 change: 1 addition & 0 deletions src/verus.pest
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,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 @@ -2563,3 +2563,41 @@ verus! {
} // 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!
"###)
}