Skip to content

Disambiguation priority not preserved when importing modules #4364

Open
@xumingkuan

Description

@xumingkuan

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

Metadata

Metadata

Assignees

Labels

during 4: bad execution of correct programA bug in the Dafny compiler that causes a correct Dafny program to execute incorrectlyhas-workaround: yesThere is a known workaroundkind: bugCrashes, unsoundness, incorrect output, etc. If possible, add a `part:` labelpart: resolverResolution and typecheckingpriority: nextWill consider working on this after in progress work is done

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions