Open
Description
Dafny version
4.1.0
Code to produce this issue
module A {
datatype T = foo(int)
function foo(x: int): int {
x * x
}
method M() {
var x := foo(100);
print x, "\n";
}
}
module B {
import opened A
method M() {
var x := foo(100);
print x, "\n";
}
}
method Main() {
A.M();
B.M();
}
Command to run and resulting output
output:
Dafny program verifier finished with 1 verified, 0 errors
10000
100
(If "print" doesn't work, you can also write `assert x == 10000;` in both methods. The one in `A` passes and the one in `B` does not type check.)
What happened?
In A
, foo
is resolved correctly to the function because it has a higher priority than the datatype constructor.
In B
, however, such priorities are not preserved when we import the module A
. foo
is resolved as a datatype constructor instead.
What type of operating system are you experiencing the problem on?
Mac