diff options
author | cooldome <ariabushenko@gmail.com> | 2021-01-11 09:09:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 10:09:38 +0100 |
commit | 0286a0879bc44e5267a5fd36e6f4aac8f78713ea (patch) | |
tree | 727a46cfaf53236a064d6e53223cfb0cfd518593 /tests | |
parent | 510e383d9233641a82ef25d3e3fe3e2eba3a4388 (diff) | |
download | Nim-0286a0879bc44e5267a5fd36e6f4aac8f78713ea.tar.gz |
fix #16651 (#16658)
* fix #16651
Diffstat (limited to 'tests')
-rw-r--r-- | tests/converter/tgenericconverter.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/converter/tgenericconverter.nim b/tests/converter/tgenericconverter.nim index e1c9f7c4c..cbbd2e1b0 100644 --- a/tests/converter/tgenericconverter.nim +++ b/tests/converter/tgenericconverter.nim @@ -28,3 +28,27 @@ aa.x = 666 p aa q aa + + +#------------------------------------------------------------- +# issue #16651 +type + PointTup = tuple + x: float32 + y: float32 + +converter tupleToPoint[T1, T2: SomeFloat](self: tuple[x: T1, y: T2]): PointTup = + result = (self.x.float32, self.y.float32) + +proc tupleToPointX(self: tuple[x: SomeFloat, y: SomeFloat]): PointTup = + result = (self.x.float32, self.y.float32) + +proc tupleToPointX2(self: tuple[x: SomeFloat, y: distinct SomeFloat]): PointTup = + result = (self.x.float32, self.y.float32) + +var t1: PointTup = tupleToPointX((1.0, 0.0)) +var t2: PointTup = tupleToPointX2((1.0, 0.0)) +var t3: PointTup = tupleToPointX2((1.0'f32, 0.0)) +var t4: PointTup = tupleToPointX2((1.0, 0.0'f32)) + +var x2: PointTup = (1.0, 0.0) \ No newline at end of file |