summary refs log tree commit diff stats
path: root/tests/generics
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-09-03 06:45:44 +0300
committerGitHub <noreply@github.com>2024-09-03 05:45:44 +0200
commit1ebdcb3bcaac3259193de6f8ce1d94889c3dc100 (patch)
tree9e3d976b19dae0d9205f768617ac530550fe87a7 /tests/generics
parentd27061f6dabf99255dd677595bed1d9a97ec135e (diff)
downloadNim-1ebdcb3bcaac3259193de6f8ce1d94889c3dc100.tar.gz
fully disable static paramTypesMatch for tyFromExpr in generics (#24049)
fixes #24044

When matching a `tyFromExpr` against a `static` generic parameter,
`paramTypesMatch` tries to evaluate it as a constant expression, which
causes a segfault in the case of #24044. In #24005 a consequence of the
same behavior was an issue where `nkStaticExpr` was created for
`tyFromExpr` which made it not instantiate, so only the generation of
`nkStaticExpr` was disabled. Instead we now just completely ignore
`tyFromExpr` matching a `static` generic parameter in generic contexts
and keep it untouched.
Diffstat (limited to 'tests/generics')
-rw-r--r--tests/generics/tuninstantiatedgenericcalls.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/generics/tuninstantiatedgenericcalls.nim b/tests/generics/tuninstantiatedgenericcalls.nim
index b5be434aa..45de24459 100644
--- a/tests/generics/tuninstantiatedgenericcalls.nim
+++ b/tests/generics/tuninstantiatedgenericcalls.nim
@@ -325,6 +325,14 @@ block: # issue #12714
     MyChannel[T: Enqueueable] = object
       dummy: type(default(T)[])
 
+block: # issue #24044
+  type ArrayBuf[N: static int, T = byte] = object
+    buf: array[N, T]
+  template maxLen(T: type): int =
+    sizeof(T) * 2
+  type MyBuf[I] = ArrayBuf[maxLen(I)]
+  var v: MyBuf[int]
+
 when false: # issue #22342, type section version of #22607
   type GenAlias[isInt: static bool] = (
     when isInt: