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

Allow writing function contracts in webassembly code #407

Open
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

Laplace-Demon
Copy link
Collaborator

No description provided.

@Laplace-Demon
Copy link
Collaborator Author

Laplace-Demon commented Aug 13, 2024

(module
    (@contract $plus_three
        (ensures (= result (+ (param 0) 3)))
    )
    (func $plus_three
        (param $x i32) (result i32)
        (i32.add (i32.const 3) (local.get $x)))
    (func $f1)
    (func $f2)
    (func $start
        (call $plus_three (i32.const 42))
        drop)
    (start $start)
)

https://github.com/OCamlPro/owi/pull/407/files#diff-7c2dae9082c169cc2debcfa373c659698275723c46bacea33467d954f5dcf87cR506

I'm expecting get _ modul.func (Text "plus_three") or get _ modul.func (Raw 0) to return the function $plus_three. But now it returns the function $start.

Upd: I mistook the use of get. It returns the i-th object of the indexed list, while we should use Indexed.get_at here.

@zapashcanon zapashcanon mentioned this pull request Aug 13, 2024
src/annot/contract.ml Outdated Show resolved Hide resolved
src/annot/contract.ml Outdated Show resolved Hide resolved
src/annot/contract.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
src/annot/spec.ml Outdated Show resolved Hide resolved
test/conc/plus.wat Outdated Show resolved Hide resolved
test/conc/plus.wat Outdated Show resolved Hide resolved
src/cmd/cmd_rac.ml Outdated Show resolved Hide resolved
@zapashcanon
Copy link
Member

Thanks! I think you can add something in CHANGES.md. Also, could you add an example as you did for E-ACSL?

@zapashcanon
Copy link
Member

zapashcanon commented Sep 6, 2024

Perfect! Could you add a small test with a .wat file containing an assert and call it with owi run --rac to simply check that it works correctly ? (Or it can simply contains some code with Weasel specifications, which should generate the assert)

@zapashcanon
Copy link
Member

One more thing I am thinking of, instead of requiring an assert function from the host in the concrete case, we could simply compile the code to if (!cond) then unreachable, right?

@Laplace-Demon
Copy link
Collaborator Author

One more thing I am thinking of, instead of requiring an assert function from the host in the concrete case, we could simply compile the code to if (!cond) then unreachable, right?

Yes, but that depends on how we want our assert? Passing some meta-information of assertion (such as to which clause and contract it corresponds) may be useful, in E-ACSL they register 1. whether a failure of this assertion block the execution 2. the specification clause 3. the file name 4. the line number. For me I think showing the failing specification may be of help

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

Successfully merging this pull request may close these issues.

2 participants