summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-08-31 22:30:19 +0800
committerGitHub <noreply@github.com>2023-08-31 22:30:19 +0800
commit5387b302117bbbc8c52ff2bed416b10a564e8b15 (patch)
treecdffdca88b8a1c0b80d577bec325c0f6c8285fd4 /tests
parent5bd1afc3f9716fed833b7bd251ee45479b78a950 (diff)
downloadNim-5387b302117bbbc8c52ff2bed416b10a564e8b15.tar.gz
closes #22600; adds a test case (#22602)
closes #22600
Diffstat (limited to 'tests')
-rw-r--r--tests/statictypes/tstatictypes.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim
index ac84c4a31..24c99b26b 100644
--- a/tests/statictypes/tstatictypes.nim
+++ b/tests/statictypes/tstatictypes.nim
@@ -411,3 +411,28 @@ block: # Ensure static descriminated objects compile
   discard instance
   discard MyObject[KindC]()
 
+block: # bug #22600
+  proc f(n: static int): int = n * 2 # same for template
+
+  type
+    a[N: static int] = object
+      field : array[N, uint8]
+
+    b[N: static int] = object
+      field : a[N]
+
+    c[N: static int] = object
+      f0    : a[N     ]         # works
+      f1    : a[N + 1 ]         # asserts
+      f2    : a[f(N)  ]         # asserts
+
+      f3    : b[N     ]         # works
+      f4    : b[N + 1 ]         # asserts
+      f5    : b[f(N)  ]         # asserts
+
+  proc init[N: static int](x : var a[N]) = discard
+  proc init[N: static int](x : var b[N]) = discard
+  proc init[N: static int](x : var c[N]) = x.f1.init() # this is needed
+
+  var x: c[2]
+  x.init()