Quantcast
Channel: Dafny: An Automatic Program Verifier for Functional Correctness
Viewing all articles
Browse latest Browse all 1106

Commented Unassigned: Generic type equality for datatypes with iset and imap [162]

$
0
0
The example below gives errors about type equality in the A and C cases, but not the B or D cases, nor in the cases that don't use datatypes, which suggests there's a datatype-related code path that's not being handled correctly for iset and imap. Specifically, the error says:

> Error: type parameter 0 (T) passed to method foo must support equality (got A)

```
method foo<T(==)>(x:T)

datatype A = A(s:iset<int>)
datatype B = B(s:set<int>)
datatype C = C(s:imap<int,int>)
datatype D = D(s:map<int,int>)

method bar()
{
var a:A;
foo(a);

var b:B;
foo(b);

var c:C;
foo(c);

var d:D;
foo(d);

var s:iset<int>;
foo(s);

var s':imap<int,int>;
foo(s');
}
```
Comments: I just want to add a remark, because there's a subtlety with this issue. In general, it would not be achievable at run-time to compare two possibly infinite sets or maps for equality, and thus it is not in general achievable to compare two values of type `A` or `C` at run time. However, it so happens that any `iset` or `imap` that is part of a run-time execution is finite. Therefore, it is in practice achievable to compare `iset`, `imap`, `A`, and `C` values as run time. Thanks for the bug report and for the fix! Rustan

Viewing all articles
Browse latest Browse all 1106

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>