dafny-lang / dafny

Dafny is a verification-aware programming language

Home Page:https://dafny.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No line/column information reported on some type errors when a datatype extends a trait

dschoepe opened this issue · comments

Dafny version

4.6.0+da8b84f362bf482160ae2604e4ae6d3c62231dae

Code to produce this issue

class A {}

trait Clone<Self> {
  method clone() returns (res: Self)
}

datatype B extends Clone<B> = B() {
  method clone() returns (res: B)
  {
    res := this;
  }
}

method assertEq_<T>(left: T, right: T) {}

type {:extern} Extern {
  method toA() returns (res: A)
}

method foo(ext: Extern, b: B) {
  var x := ext.toA();
  assertEq_(b, x);
}

Command to run and resulting output

dafny verify --type-system-refresh --verbose --general-traits=datatype --isolate-assertions --cores 8 --verification-time-limit 60 --log-format text /Users/schoeped/tmp/NoLineInfo.dfy

What happened?

The above program is not well-typed and produces an error without valid line/column numbers making it hard to pinpoint where in a larger file the error originates:

(0,-1): Error: incorrect argument type at index 1 for method in-parameter 'right' (expected B, found A?)
1 resolution/type errors detected in NoLineInfo.dfy

Instead, I'd expect the error to point to the assertEq_ line; for example when removing the (unused) extends Clone<B> clause on B, the following error is produced:

NoLineInfo.dfy(21,11): Error: incorrect return type for method out-parameter 'res' (expected A, got B)
   |
21 |   var x := ext.toA();
   |            ^^^^^^^^^

What type of operating system are you experiencing the problem on?

Mac