summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-06-10 22:29:33 +0300
committerAndreas Rumpf <rumpf_a@web.de>2017-06-20 11:29:42 +0200
commit92ee2ee4ce0958126ba0b22edfebc4aa76fd7f3d (patch)
tree623ca47a7bf4dd1c57953b38b4b5069aec1a37de
parentba61e7e3ac0c2e1b323f97145645336e7f2e684c (diff)
downloadNim-92ee2ee4ce0958126ba0b22edfebc4aa76fd7f3d.tar.gz
close #4524
-rw-r--r--tests/metatype/tstaticparams.nim12
-rw-r--r--tests/statictypes/tpassthruarith.nim12
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/metatype/tstaticparams.nim b/tests/metatype/tstaticparams.nim
index 11653e563..52a501e39 100644
--- a/tests/metatype/tstaticparams.nim
+++ b/tests/metatype/tstaticparams.nim
@@ -1,6 +1,6 @@
 discard """
   file: "tstaticparams.nim"
-  output: "abracadabra\ntest\n3\n15\n4\n2\nfloat\n3\nfloat\nyin\nyang"
+  output: "abracadabra\ntest\n3\n15\n4\n2\nfloat\n3\nfloat\nyin\nyang\n2"
 """
 
 type
@@ -140,3 +140,13 @@ dontBind1 bb_2
 dontBind2 bb_1
 dontBind2 bb_2
 
+# https://github.com/nim-lang/Nim/issues/4524 
+const
+  size* = 2
+
+proc arraySize[N: static[int]](A: array[N, int]): int =
+  result = A.high - A.low + 1
+
+var A: array[size, int] = [1, 2]
+echo arraySize(A)
+
diff --git a/tests/statictypes/tpassthruarith.nim b/tests/statictypes/tpassthruarith.nim
index 25cc46bad..90fc7824c 100644
--- a/tests/statictypes/tpassthruarith.nim
+++ b/tests/statictypes/tpassthruarith.nim
@@ -7,6 +7,8 @@ output: '''
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+
+[1, 2, 3, 4]
 '''
 """
 
@@ -40,3 +42,13 @@ echo repr(m)
 echo repr(n)
 echo repr(o)
 
+type
+  Vect[N: static[int], A] = array[N, A]
+
+proc push[N: static[int], A](a: Vect[N, A], x: A): Vect[N + 1, A] =
+  for n in 0 .. < N:
+    result[n] = a[n]
+  result[N] = x
+
+echo repr(push([1, 2, 3], 4))
+