Skip to content

Commit

Permalink
Enable reads checks on statements outside of method contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-aws committed Aug 22, 2023
1 parent 38cdbf5 commit a00fc44
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Source/DafnyCore/Verifier/Translator.TrStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,13 +1885,16 @@ void ProcessCallStmt(IToken tok,
}
}

// Check reads/modifies clause of a subcall is a subset of the current frame.
// Check that the reads clause of a subcall is a subset of the current reads frame,
// but support the optimization that we don't define a reads frame at all if it's `reads *`.
if (etran.readsFrame != null) {
var readsSubst = new Substituter(null, new Dictionary<IVariable, Expression>(), tySubst);
CheckFrameSubset(tok, callee.Reads.ConvertAll(readsSubst.SubstFrameExpr),
receiver, substMap, etran, etran.ReadsFrame(tok), builder, new PODesc.FrameSubset("call", false), null);
}
// Check that the modifies clause of a subcall is a subset of the current modifies frame,
// but only if we're in a context that defines a modifies frame.
if (codeContext is IMethodCodeContext) {
if (etran.readsFrame != null) {
var readsSubst = new Substituter(null, new Dictionary<IVariable, Expression>(), tySubst);
CheckFrameSubset(tok, callee.Reads.ConvertAll(readsSubst.SubstFrameExpr),
receiver, substMap, etran, etran.ReadsFrame(tok), builder, new PODesc.FrameSubset("call", false), null);
}
var modifiesSubst = new Substituter(null, new Dictionary<IVariable, Expression>(), tySubst);
CheckFrameSubset(tok, callee.Mod.Expressions.ConvertAll(modifiesSubst.SubstFrameExpr),
receiver, substMap, etran, etran.ModifiesFrame(tok), builder, new PODesc.FrameSubset("call", true), null);
Expand Down

0 comments on commit a00fc44

Please sign in to comment.