Replies: 3 comments 1 reply
-
Another case where havoc assignment causes trouble is when a datatype is built with a trait or class. datatype dt1 = dt1(a: int)
datatype dt2 = dt2(a: int, b: boilerplate)
datatype dt3 = dt3(a: int, b: array<myTrait>)
method myOtherMethod<T>(d: T) returns (b:bool) { return true; }
method main(){
var d1: dt1 := *;
var r:= myOtherMethod(d1); //OK
var d2: dt2 := *;
var r2:= myOtherMethod(d2); //FAILS: variable 'd2', which is subject to definite-assignment rules, might be uninitialized here
var d3: dt3 := *;
var r3:= myOtherMethod(d3); //OK
} |
Beta Was this translation helpful? Give feedback.
-
Would it be helpful if I break this issue down into smaller issues? |
Beta Was this translation helpful? Give feedback.
-
No, this is fine. Sorry for the slow response. I will try to improve our processes so we're faster next time :-)
This seems fine, although you don't need the
I created a ticket to improve our error reporting, that should explain what's going on here: #5362
I believe the syntax error there is expected, since havoc assignment is a statement, not an expression. I could create a ticket to improve the parser's error reporting, but that's quite far down the line for us, so I'll let this be for now. Do you have any remaining questions? |
Beta Was this translation helpful? Give feedback.
-
Dafny version
4.0.0
Code to produce this issue
Command to run and resulting output
What happened?
Repeating here for convenience the questions in the code :
What type of operating system are you experiencing the problem on?
Mac
Beta Was this translation helpful? Give feedback.
All reactions