-
Notifications
You must be signed in to change notification settings - Fork 54
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
POC: Make ensuring inline #1624
base: main
Are you sure you want to change the base?
Conversation
This PR makes extension [A](x: A)
@library inline def ensuring(@ghost inline cond: A => Boolean, inline msg: String = ""): A = x Therefore when compiling: def f(x: Int): Int = {
require(x >= 0)
val res = if x == Integer.MAX_VALUE then x else x + 1
res
}.ensuring(_ > 0) After inlining we get: def f(x: Int): Int = {
val x$1: Int = {
require(x.>=(0))
val res: Int = if x.==(Integer.MAX_VALUE) then x else x.+(1)
res:Int
}
x$1:Int
} Note how the From my understanding, I would therefore expect |
6445b1b
to
7224d8c
Compare
7224d8c partially fixes extraction of nested inlined import stainless.lang.StaticChecks.*
case class FileInputStream() {
def tryReadByte(isOpen: Boolean): Int = {
require(isOpen)
def impl(): Int = {
require(isOpen)
0
}.ensuring(_ => isOpen)
impl()
}.ensuring(_ => isOpen)
} is extracted to: case class FileInputStream {
@method(FileInputStream)
def tryReadByte(isOpen: Boolean): Int = {
require(@ghost isOpen)
@final
def impl: Int = {
require(@ghost isOpen)
0
}.ensuring {
(_$1: Int) => @ghost isOpen
}
impl
}.ensuring {
(_$2: Int) => @ghost isOpen
}
} |
I found that |
After discussing with @samuelchassot, I think a better approach than trying to "de-inline" calls to |
No description provided.