Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Source/DafnyCore/Verifier/BoogieGenerator.Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ void AddFunction_Top(Function f, bool includeAllMethods) {
}

void AddMethod_Top(MethodOrConstructor m, bool isByMethod, bool includeAllMethods) {
if (!includeAllMethods && !InVerificationScope(m) && !referencedMembers.Contains(m)) {
if (!includeAllMethods &&
m.EnclosingClass.EnclosingModuleDefinition != forModule &&
!referencedMembers.Contains(m)) {
// do nothing
return;
}
Expand Down
7 changes: 6 additions & 1 deletion Source/DafnyCore/Verifier/BoogieGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ private void EstablishModuleScope(ModuleDefinition systemModule, ModuleDefinitio

private ProofDependencyManager proofDependencies;

// optimizing translation
/**
* The behavior around this field assumes that usages are visited before declarations
* which is only the case when the usage is in a different module than the declaration.
* However, we alleviate this problem by saying that any declaration must be kept
* if any code in that module is verified.
*/
readonly ISet<MemberDecl> referencedMembers = new HashSet<MemberDecl>();

public void AddReferencedMember(MemberDecl m) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

method Foo() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %verify "%s" &> "%t"
// RUN: %diff "%s.expect" "%t"

include "Inputs/producer.dfy"

class X {
method Bar() {
Foo();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Dafny program verifier finished with 1 verified, 0 errors
1 change: 1 addition & 0 deletions docs/news/6192.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prevent an exception that could occur when using includes and top level members
Loading