Constraint-less newtypes assumed to be nonempty #5521
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
kind: bug
Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
Dafny version
4.6.0
Code to produce this issue
Command to run and resulting output
What happened?
A constraint-less
newtype
(that is, a declaration of the formnewtype N = T
for some previous typeT
) is only as nonempty as its base type. Yet, Dafny assumesNewEmpty
to be nonempty. (This was correct years ago, before Dafny started supporting empty types.)To fix this issue, the verifier should perform a non-emptiness test on constraint-less
newtype
s, just as if the type had been declared with a (trivial) constraint:If this test fails and Dafny reports an error, then it would be nice to let the program declare a
witness
clause on the constraint-lessnewtype
. However, at this time, onlynewtype
declarations with constraints are (syntactically) allowed awitness
clause. I propose that this be changed at the same time as the soundness bug is fixed.What type of operating system are you experiencing the problem on?
Mac
The text was updated successfully, but these errors were encountered: