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

Counterexamples don't show #505

Closed
RustanLeino opened this issue Oct 23, 2024 · 1 comment
Closed

Counterexamples don't show #505

RustanLeino opened this issue Oct 23, 2024 · 1 comment

Comments

@RustanLeino
Copy link
Contributor

Using the Dafny IDE 4.3.1 with Dafny 4.8.1, the "Show counterexample (F7)" feature gives an error:

Counterexample request failed: TypeError: Cannot convert undefined or null to object

Repro

Load the following code into VS Code. Notice that an error is reported. Select "Show counterexample" from the right-click Dafny menu or press F7. That gives the error.

method BinarySearch(a: array<int>, key: int) returns (r: int)
  requires forall i, j :: 0 <= i < j < a.Length ==> a[i] <= a[j]
  ensures 0 <= r ==> r < a.Length && a[r] == key
  ensures r < 0 ==> key !in a[..]
{
  var lo, hi := 0, a.Length;
  while lo < hi
    invariant 0 <= lo <= hi <= a.Length
    invariant key !in a[..lo] && key !in a[hi..]
  {
    var mid := lo + (hi - lo) / 2;
    if a[mid] == key {
      return mid;
    } else if key < a[mid] {
      hi := mid;
    } else {
      lo := mid; // there's an error on this line
    }
  }
  r := -1;
}
@keyboardDrummer
Copy link
Member

Duplicate of #492

@keyboardDrummer keyboardDrummer marked this as a duplicate of #492 Oct 24, 2024
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