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

Function precondition not maintained for subsequent calls #862

Closed
brson opened this issue Aug 24, 2011 · 1 comment
Closed

Function precondition not maintained for subsequent calls #862

brson opened this issue Aug 24, 2011 · 1 comment

Comments

@brson
Copy link
Contributor

brson commented Aug 24, 2011

Similar to #694:

pred p(j: int) -> bool { true }

fn f(i: int, j: int) : p(j) -> int { j }

fn g(i: int, j: int) : p(j) -> int { f(i, j) }
../src/test/run-pass/typestate.rs:8:37:8:44: error: Unsatisfied precondition constraint (for example, p(j)[../src/test/run-pass/typestate.rs:6:23:6:27]) for expression:
f(i, j)
Precondition:
p(j)[../src/test/run-pass/typestate.rs:6:23:6:27], init(j [../src/test/run-pass/typestate.rs:8:0:8:46]), init(i [../src/test/run-pass/typestate.rs:8:0:8:46])
Prestate:
!p(j)[../src/test/run-pass/typestate.rs:6:23:6:27], p(i, j)[../src/test/run-pass/typestate.rs:8:23:8:27], init(j [../src/test/run-pass/typestate.rs:8:0:8:46]), init(i [../src/test/run-pass/typestate.rs:8:0:8:46]), !init(g [../src/test/run-pass/typestate.rs:8:0:8:46]), !init(g! [../src/test/run-pass/typestate.rs:8:0:8:46])
../src/test/run-pass/typestate.rs:8 fn g(i: int, j: int) : p(j) -> int { f(i, j) }

This problem is affecting std::str::replace

@ghost ghost assigned catamorphism Aug 24, 2011
@catamorphism
Copy link
Contributor

It was actually worse than that -- any typestate constraints that weren't of the form p(x1, x2, ..., xn) on a function decl of the form f(x1:t1, x2:t2, ..., xn:tn) weren't working. Fix coming up.

keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants