Skip to content

Commit

Permalink
Don't attempt to parse a range as a float
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybosamiya committed Mar 12, 2024
1 parent f087358 commit 0456f2b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Improve parsing of range expressions (e.g., `0..(1 + 2)`) that start "float-like"

# v0.2.7

* Improve `verus!{ ... }` macro collapsing inside indented contexts (#39)
Expand Down
2 changes: 1 addition & 1 deletion src/verus.pest
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int_number = @{

float_decimal = @{
(ASCII_DIGIT | "_")+ ~
"." ~
!".." ~ "." ~
(ASCII_DIGIT | "_")* ~
("f32" | "f64")?
}
Expand Down
24 changes: 24 additions & 0 deletions tests/verus-consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,3 +1675,27 @@ proof fn uses_arrow_matches_1(t: ThisOrThat) { assert(t matches ThisOrThat::This
} // verus!
"###);
}

#[test]
fn verus_range_operator() {
let file = r#"
verus! {
fn foo() { for i in 0..(10 + 5) {
} }
}
"#;
assert_snapshot!(parse_and_format(file).unwrap(), @r###"
verus! {
fn foo() {
for i in 0..(10 + 5) {
}
}
} // verus!
"###);
}

0 comments on commit 0456f2b

Please sign in to comment.