Skip to content

Commit

Permalink
Add a missing expression clone (#3346)
Browse files Browse the repository at this point in the history
During PR #2734, a refactoring of the cloner mistakenly omitted a clone
call for one sub-expression of TypeRHS, leading to issue #3343.

This PR reinstates that clone.

Fixes #3343.
  • Loading branch information
atomb authored Jan 10, 2023
1 parent 1ad148e commit 87eeef2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/DafnyCore/AST/Statements/Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public TypeRhs(Cloner cloner, TypeRhs original)
if (original.ArrayDimensions != null) {
if (original.InitDisplay != null) {
Contract.Assert(original.ArrayDimensions.Count == 1);
ArrayDimensions = new List<Expression> { original.ArrayDimensions[0] };
ArrayDimensions = new List<Expression> { cloner.CloneExpr(original.ArrayDimensions[0]) };
InitDisplay = original.InitDisplay.ConvertAll(cloner.CloneExpr);
} else {
ArrayDimensions = original.ArrayDimensions.Select(cloner.CloneExpr).ToList();
Expand Down
6 changes: 6 additions & 0 deletions Test/git-issues/github-issue-3343.dfy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %baredafny run "%s" -t:java > "%t"
// RUN: %diff "%s.expect" "%t"
method Bug() {
var zero := 0;
var a := new int[zero] [];
}
2 changes: 2 additions & 0 deletions Test/git-issues/github-issue-3343.dfy.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Dafny program verifier finished with 1 verified, 0 errors

0 comments on commit 87eeef2

Please sign in to comment.