Inconsistent printing of unordered collections across backends #4108
Labels
kind: enhancement
Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
part: runtime
Happens in Dafny's runtime (Add a `lang` tag if relevant)
testing-method: uniform-backend-testing
Issues found by ensuring uniform testing across backends
This is one of those issues that most of us are fully aware of but have lived with for a long time without writing down (unless I just can't find the existing issue).
Not really a bug per se since the behavior of
print
is underspecified, but this makes consistent differential testing really annoying, whether testing a user program or the backends themselves.My proposal for the most beneficial solution: implement the collections such as
set
,multiset
andmap
in Dafny in the same way we now have a Dafny implementation ofseq
: https://github.com/dafny-lang/dafny/blob/master/Source/DafnyRuntime/DafnyRuntimeDafny/src/dafnyRuntime.dfy. This would depend on having a common implementation of hash code functions for all Dafny types, instead of relying on target language runtime hash codes. We'd then have unpredictable but deterministic ordering for these collections. This is also worth doing in order to provide more efficient implementations of these immutable data types, rather than wrapping mutable versions from the target runtimes and making expensive defensive copies everywhere.See also #2062.
The text was updated successfully, but these errors were encountered: