diff options
author | Zahary Karadjov <zahary@gmail.com> | 2017-06-10 18:01:10 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-20 11:29:42 +0200 |
commit | 9edf66df85dcd59e97026ea4273f9e8e5fee6cc5 (patch) | |
tree | 86b29de76c8b49290d8f1d1da5a6e6eecf889236 /tests | |
parent | f713e730c8467968be9efe27232e81203fc6c0cd (diff) | |
download | Nim-9edf66df85dcd59e97026ea4273f9e8e5fee6cc5.tar.gz |
close #5756
Diffstat (limited to 'tests')
-rw-r--r-- | tests/generics/treentranttypes.nim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/generics/treentranttypes.nim b/tests/generics/treentranttypes.nim index e79451314..9b4774e9b 100644 --- a/tests/generics/treentranttypes.nim +++ b/tests/generics/treentranttypes.nim @@ -16,6 +16,11 @@ output: ''' 2x3 VectorVector [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] 2x3 VectorArray [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] + +@[1, 2] +@[1, 2] +@[1, 2]@[3, 4] +@[1, 2]@[3, 4] ''' """ @@ -79,3 +84,28 @@ proc arrayTest = arrayTest() +# https://github.com/nim-lang/Nim/issues/5756 + +type + Vec*[N : static[int]] = object + arr*: array[N, int32] + + Mat*[M,N: static[int]] = object + arr*: array[M, Vec[N]] + +proc vec2*(x,y:int32) : Vec[2] = + result.arr = [x,y] + +proc mat2*(a,b: Vec[2]): Mat[2,2] = + result.arr = [a,b] + +const a = vec2(1,2) +echo @(a.arr) +let x = a +echo @(x.arr) + +const b = mat2(vec2(1, 2), vec2(3, 4)) +echo @(b.arr[0].arr), @(b.arr[1].arr) +let y = b +echo @(y.arr[0].arr), @(y.arr[1].arr) + |