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

Missing modifies clause is not detected #23

Open
fpottier opened this issue Feb 16, 2022 · 4 comments
Open

Missing modifies clause is not detected #23

fpottier opened this issue Feb 16, 2022 · 4 comments

Comments

@fpottier
Copy link

The following .ml file is accepted by Cameleer:

let write a =
  a.(0) <- 1
(*@ write a
    requires Array.length a > 0
    ensures a.(0) = 1 *)

I am surprised; I thought that in such a case, it is necessary to declare modifies a. Is this a bug, or is it the intended behavior?

@mariojppereira
Copy link
Collaborator

Good catch. In fact, I am currently not imposing modifies in OCaml implementations since Why3 automatically detects every writing effect. Hence, the OCaml to WhyML translation automatically introduces the appropriate modifies.

Would you be in favor of imposing modifies even for implementations? If so, your example would generate the following WhyML program:

  let write a
    writes { }
  = a[0] <- 1

which of course would be rejected by Why3 type-system.

@fpottier
Copy link
Author

I would be in favor of enforcing the same discipline, regardless of whether the specification appears in an .ml or .mli file. Otherwise, this is confusing (and prevents copying/pasting).

@mariojppereira
Copy link
Collaborator

Okay, I will implement this.

@fpottier
Copy link
Author

That said, we probably need to have a discussion about the meaning of (and the need for) modifies clauses in Gospel; this is related to the manner in which we wish to deal with aliasing and ownership in Gospel.

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