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

Problem with coercion int to integer in pattern matching #172

Closed
n-osborne opened this issue Nov 6, 2023 · 0 comments · Fixed by #174
Closed

Problem with coercion int to integer in pattern matching #172

n-osborne opened this issue Nov 6, 2023 · 0 comments · Fixed by #174

Comments

@n-osborne
Copy link
Collaborator

Here, gospel check succeed because 0 is coerced to an integer.

type 'a t
(*@ mutable model contents : 'a sequence *)

val create : unit -> 'a t
(*@ q = create ()
    ensures q.contents = Sequence.empty *)

val pop_opt : 'a t -> 'a option
(*@ o = pop_opt q
    modifies q.contents
    ensures q.contents = match Sequence.length (old q.contents) with
                          | 0 -> Sequence.empty
                          | _ -> Sequence.tl (old q.contents) *)

But, in the generated code, 0 is an int:

    let next_state cmd__002_ state__003_ =
      match cmd__002_ with
      | Pop_opt ->
          {
            contents =
              ((try
                  match Ortac_runtime.Gospelstdlib.Sequence.length
                          state__003_.contents
                  with
                  | 0 -> Ortac_runtime.Gospelstdlib.Sequence.empty
                  | _ ->
                      Ortac_runtime.Gospelstdlib.Sequence.tl
                        state__003_.contents
                with
                | e -> ...
          }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant