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

Empty type of let variable assumed before binding #1958

Open
RustanLeino opened this issue Apr 1, 2022 · 1 comment
Open

Empty type of let variable assumed before binding #1958

RustanLeino opened this issue Apr 1, 2022 · 1 comment
Labels
during 3: execution of incorrect program An bug in the verifier that allows Dafny to run a program that does not correctly implement its spec introduced: v3.0.0 kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator) priority: next Will consider working on this after in progress work is done status: needs-info Issue requires more information from poster

Comments

@RustanLeino
Copy link
Collaborator

The following program verifies, but should not:

type R = r: BaseType | r.i() witness *

function F(v: nat): R {
  var o: R := Ctor(v);
  o
}

The following similar code, but without the let expression, does produce an error (which is good):

function G(v: nat): R {
  Ctor(v) // error: This does not produce an R
}

A quick look at the generated Boogie shows that var o: R ... generates an assumption about o's type before the RHS has been evaluated and checked. That assumption should not be there (at least for a possibly empty type).

@RustanLeino RustanLeino added kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label logic An inconsistency in Dafny's logic (e.g. in the Boogie prelude) labels Apr 1, 2022
@cpitclaudel cpitclaudel added the status: needs-info Issue requires more information from poster label May 13, 2022
@cpitclaudel
Copy link
Member

@RustanLeino it looks like your OP is missing some context. Do you still have the full example?

In the meantime, here's one possible completion:

type BaseType {
  predicate i()
}

function Ctor(x: nat) : R
  requires exists b: BaseType :: b.i()
{ var b : BaseType :| b.i(); b }

type R = r: BaseType | r.i() witness *

function F(v: nat): R {
  var o: R := Ctor(v);
  o
}

@cpitclaudel cpitclaudel added during 3: execution of incorrect program An bug in the verifier that allows Dafny to run a program that does not correctly implement its spec and removed logic An inconsistency in Dafny's logic (e.g. in the Boogie prelude) labels Sep 2, 2022
@keyboardDrummer keyboardDrummer added the priority: next Will consider working on this after in progress work is done label Feb 21, 2024
@keyboardDrummer keyboardDrummer added the part: verifier Translation from Dafny to Boogie (translator) label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
during 3: execution of incorrect program An bug in the verifier that allows Dafny to run a program that does not correctly implement its spec introduced: v3.0.0 kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label part: verifier Translation from Dafny to Boogie (translator) priority: next Will consider working on this after in progress work is done status: needs-info Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants