Skip to content

Commit

Permalink
Use full type declaration names in Boogie generation (#5030)
Browse files Browse the repository at this point in the history
### Description

Use full type declaration names in Boogie generation. Failing to do this
was leading to spurious warnings about proofs due to contradictory
assumptions.

Fixes #5029

### How has this been tested?

`Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/github-issue-5029.dfy`

By submitting this pull request, I confirm that my contribution is made
under the terms of the MIT license.
  • Loading branch information
atomb authored Jan 31, 2024
1 parent 8221c9d commit 8bf0879
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Source/DafnyCore/AST/Members/ICodeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public NoContext(ModuleDefinition module) {
public interface RedirectingTypeDecl : ICallable {
string Name { get; }

string FullDafnyName { get; }

IToken tok { get; }
Attributes Attributes { get; }
ModuleDefinition Module { get; }
Expand Down
4 changes: 2 additions & 2 deletions Source/DafnyCore/Verifier/BoogieGenerator.Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
Contract.Requires(currentModule == null && codeContext == null && isAllocContext == null);
Contract.Ensures(currentModule == null && codeContext == null && isAllocContext == null);

proofDependencies.SetCurrentDefinition(MethodVerboseName(decl.Name, MethodTranslationKind.SpecWellformedness));
proofDependencies.SetCurrentDefinition(MethodVerboseName(decl.FullDafnyName, MethodTranslationKind.SpecWellformedness));

if (!InVerificationScope(decl)) {
// Checked in other file
Expand Down Expand Up @@ -1417,7 +1417,7 @@ void AddWellformednessCheck(RedirectingTypeDecl decl) {
var proc = new Bpl.Procedure(decl.tok, name, new List<Bpl.TypeVariable>(),
inParams, new List<Variable>(),
false, req, mod, new List<Bpl.Ensures>(), etran.TrAttributes(decl.Attributes, null));
AddVerboseNameAttribute(proc, decl.Name, MethodTranslationKind.SpecWellformedness);
AddVerboseNameAttribute(proc, decl.FullDafnyName, MethodTranslationKind.SpecWellformedness);
sink.AddTopLevelDeclaration(proc);

// TODO: Can a checksum be inserted here?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %verify "%s" --warn-contradictory-assumptions
abstract module Digit {
function BASE(): nat
ensures BASE() > 1

type digit = i: nat | 0 <= i < BASE()
}

module M refines Digit {
function BASE(): nat { 32 }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dafny program verifier finished with 4 verified, 0 errors

0 comments on commit 8bf0879

Please sign in to comment.