From b39ac541f52eefc1225961dcb781134d4c617e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= Date: Fri, 22 Jul 2022 00:04:00 -0700 Subject: [PATCH] Don't clone the body of the matches (see dafny-lang/dafny#2334) --- Source/Dafny/Resolver.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Dafny/Resolver.cs b/Source/Dafny/Resolver.cs index 504631395e0..176c88b87dc 100644 --- a/Source/Dafny/Resolver.cs +++ b/Source/Dafny/Resolver.cs @@ -11958,7 +11958,7 @@ public RBranchStmt(IToken tok, int branchid, List patterns, Lis public RBranchStmt(int branchid, NestedMatchCaseStmt x, Attributes attrs = null) : base(x.Tok, branchid, new List()) { Contract.Requires(!(x.Pat is DisjunctivePattern)); // No nested or patterns - this.Body = new List(x.Body); // Resolving the body will insert new elements. + this.Body = new List(x.Body); // Resolving the body will insert new elements. this.Attributes = attrs; this.Patterns.Add(x.Pat); } @@ -12527,14 +12527,14 @@ private IEnumerable FlattenDisjunctivePatterns(ExtendedPattern private IEnumerable 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 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(c.Body), c.Attributes); } }