Skip to content

Commit

Permalink
Don't clone the body of the matches (see #2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpitclaudel committed Jul 22, 2022
1 parent 5dbd839 commit b39ac54
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Dafny/Resolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11958,7 +11958,7 @@ public RBranchStmt(IToken tok, int branchid, List<ExtendedPattern> patterns, Lis

public RBranchStmt(int branchid, NestedMatchCaseStmt x, Attributes attrs = null) : base(x.Tok, branchid, new List<ExtendedPattern>()) {
Contract.Requires(!(x.Pat is DisjunctivePattern)); // No nested or patterns
this.Body = new List<Statement>(x.Body); // Resolving the body will insert new elements.
this.Body = new List<Statement>(x.Body); // Resolving the body will insert new elements.
this.Attributes = attrs;
this.Patterns.Add(x.Pat);
}
Expand Down Expand Up @@ -12527,14 +12527,14 @@ private IEnumerable<ExtendedPattern> FlattenDisjunctivePatterns(ExtendedPattern
private IEnumerable<NestedMatchCaseExpr> FlattenNestedMatchCaseExpr(NestedMatchCaseExpr c) {
var cloner = new Cloner();
foreach (var pat in FlattenDisjunctivePatterns(c.Pat)) {
yield return new NestedMatchCaseExpr(c.Tok, pat, cloner.CloneExpr(c.Body), cloner.CloneAttributes(c.Attributes));
yield return new NestedMatchCaseExpr(c.Tok, pat, c.Body, c.Attributes);
}
}

private IEnumerable<NestedMatchCaseStmt> FlattenNestedMatchCaseStmt(NestedMatchCaseStmt c) {
var cloner = new Cloner();
foreach (var pat in FlattenDisjunctivePatterns(c.Pat)) {
yield return new NestedMatchCaseStmt(c.Tok, pat, c.Body.ConvertAll(cloner.CloneStmt), cloner.CloneAttributes(c.Attributes));
yield return new NestedMatchCaseStmt(c.Tok, pat, new List<Statement>(c.Body), c.Attributes);
}
}

Expand Down

0 comments on commit b39ac54

Please sign in to comment.