-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add a test for the
sink
issue
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
tests/lang_types/tuples/tsink_generic_tuple_assignment.nim
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,24 @@ | ||
discard """ | ||
description: ''' | ||
Regression test for a bug where assigning a ``sink`` generic tuple type | ||
to a variable of non-``sink`` type led to the value being shallow copied. | ||
''' | ||
matrix: "--showir:mir_in:test --hints:off" | ||
nimout: ''' | ||
-- MIR: test | ||
scope: | ||
def x: sink Tuple[system.int] | ||
def v: Tuple[system.int] | ||
v = sink x | ||
-- end | ||
''' | ||
""" | ||
|
||
type Tuple[T] = (T, T) | ||
|
||
proc test(x: sink Tuple[int]) = | ||
var v: Tuple[int] | ||
v = x # this assignment was considered to involve a conversion | ||
|
||
test default(Tuple[int]) |