Skip to content

Commit

Permalink
Add test for issue 158 (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilehmann authored Oct 11, 2023
1 parent 05a937e commit 521260d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/flux-tests/tests/neg/surface/issue-158.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[path = "../../lib/rvec.rs"]
mod rvec;

use rvec::RVec;

#[flux::refined_by(size:int)]
pub struct Bob {
#[flux::field(RVec<i32{v: v > 0}>[@size])]
elems: RVec<i32>,
}

#[flux::sig(fn(&mut Bob{v: v.size > 0}) -> ())]
pub fn test(bob: &mut Bob) {
bob.elems[0] = 0; //~ ERROR refinement type
}
15 changes: 15 additions & 0 deletions crates/flux-tests/tests/pos/structs/issue-158.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[path = "../../lib/rvec.rs"]
mod rvec;

use rvec::RVec;

#[flux::refined_by(size:int)]
pub struct Bob {
#[flux::field(RVec<i32{v: v >= 0}>[@size])]
elems: RVec<i32>,
}

#[flux::sig(fn(&mut Bob{v: v.size > 0}) -> ())]
pub fn test(bob: &mut Bob) {
bob.elems[0] = 0;
}

0 comments on commit 521260d

Please sign in to comment.