Skip to content

Commit

Permalink
close #3153
Browse files Browse the repository at this point in the history
  • Loading branch information
zah authored and Araq committed Jun 20, 2017
1 parent 367d232 commit 6f93559
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/metatype/tstaticparams.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
file: "tstaticparams.nim"
output: "abracadabra\ntest\n3\n15\n4\n2\nfloat\n3\nfloat\nyin\nyang\n2"
output: "abracadabra\ntest\n3\n15\n4\n2\nfloat\n3\nfloat\nyin\nyang\n2\n4\n4\n2\n3"
"""

type
Expand Down Expand Up @@ -150,3 +150,26 @@ proc arraySize[N: static[int]](A: array[N, int]): int =
var A: array[size, int] = [1, 2]
echo arraySize(A)

# https://github.com/nim-lang/Nim/issues/3153

proc outSize1[M: static[int], A](xs: array[M, A]): int = M
echo outSize1([1, 2, 3, 4])

type
Arr[N: static[int], A] = array[N, A]

proc outSize2[M: static[int], A](xs: Arr[M, A]): int = M
echo outSize2([1, 2, 3, 4]) # 4

echo outSize2([
[1, 2, 3],
[4, 5, 6]
]) # 2

proc inSize[M, N: static[int]](xs: Arr[M, Arr[N, int]]): int = N

echo inSize([
[1, 2, 3],
[4, 5, 6]
])

0 comments on commit 6f93559

Please sign in to comment.