-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
source2il: fix missing seq copies (#111)
## Summary Fix `SeqTy` values not being copied upon being passed to union and tuple constructors, resulting in modifications of the constructed value reflecting on the original sequence (and vice versa). ## Details The `TupleCons` (tuple constructor) translation and union construction (in `fitExpr`) emitted a direct use of their operands, ignoring whether the type is trivially copyable or not. `use` - which emits a call to the type's copy procedure where needed - is now used in both cases, fixing the bug. A raw usage of `Expr.expr` part of `While` translation is - while not causing any issues - also replaced with a call to `use`. The tests for sequence copies are expanded to also cover tuple, union, and seq constructors.
- Loading branch information
Showing
5 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
discard """ | ||
output: "([1, 2, 3],): (seq(int),)" | ||
""" | ||
(Exprs | ||
(Decl x (Seq (IntTy) 1 2 3)) | ||
(Decl y (TupleCons x)) | ||
(Asgn (At x 0) 4) | ||
y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
discard """ | ||
output: "[1, 2, 3]: union(int, seq(int))" | ||
""" | ||
(Module | ||
(ProcDecl union (UnionTy (IntTy) (SeqTy (IntTy))) (Params) | ||
(Return 1)) | ||
(ProcDecl main (UnionTy (IntTy) (SeqTy (IntTy))) (Params) | ||
(Exprs | ||
(Decl x (Seq (IntTy) 1 2 3)) | ||
(Decl y (Call union)) | ||
(Asgn y x) | ||
(Asgn (At x 0) 4) | ||
(Return y)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
discard """ | ||
output: "[[1, 2, 3]]: seq(seq(int))" | ||
""" | ||
(Exprs | ||
(Decl x (Seq (IntTy) 1 2 3)) | ||
(Decl y (Seq (SeqTy (IntTy)) x)) | ||
(Asgn (At x 0) 4) | ||
y) |