Skip to content

Commit 6e6670a

Browse files
committed
Fix a few bugs
* Always have a set of IDs for a given procedure, even if empty. * Don't consider `free ensures` and `assert true` to be goals.
1 parent bac4ccd commit 6e6670a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Source/Core/CoverageAnnotator.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ public class CoverageAnnotator : StandardVisitor
1717
private Dictionary<string, ISet<string>> implementationGoalIds = new();
1818
private Dictionary<string, Absy> idMap = new();
1919

20-
private void addImplementationGoalId(string id)
20+
private void AddImplementationGoalId(string id)
2121
{
22-
implementationGoalIds.TryAdd(currentImplementation, new HashSet<string>());
2322
implementationGoalIds[currentImplementation].Add(id);
2423
}
2524

@@ -30,7 +29,7 @@ private void AddId(ICarriesAttributes node, bool isGoal)
3029
Absy absy = node as Absy;
3130
idMap.Add(idStr, absy);
3231
if (isGoal) {
33-
addImplementationGoalId(idStr);
32+
AddImplementationGoalId(idStr);
3433
}
3534
node.AddStringAttribute(absy.tok, "id", idStr);
3635
}
@@ -53,11 +52,16 @@ private void AddId(ICarriesAttributes node, bool isGoal)
5352
public override Implementation VisitImplementation(Implementation node)
5453
{
5554
currentImplementation = node.Name;
55+
implementationGoalIds.TryAdd(currentImplementation, new HashSet<string>());
5656
return base.VisitImplementation(node);
5757
}
5858

5959
public override Cmd VisitAssertCmd(AssertCmd node)
6060
{
61+
if (node.Expr is LiteralExpr {IsTrue: true}) {
62+
return node;
63+
}
64+
6165
AddId(node, true);
6266
return base.VisitAssertCmd(node);
6367
}
@@ -82,6 +86,10 @@ public override Requires VisitRequires(Requires requires)
8286

8387
public override Ensures VisitEnsures(Ensures ensures)
8488
{
89+
if (ensures.Free) {
90+
return ensures;
91+
}
92+
8593
AddId(ensures, true);
8694
return base.VisitEnsures(ensures);
8795
}

0 commit comments

Comments
 (0)