diff options
-rw-r--r-- | compiler/sigmatch.nim | 9 | ||||
-rw-r--r-- | tests/generics/tuninstantiatedgenericcalls.nim | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index b7efa8e45..c7a8c496c 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2293,6 +2293,9 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, a.n == nil and tfGenericTypeParam notin a.flags: return newNodeIT(nkType, argOrig.info, makeTypeFromExpr(c, arg)) + elif a.kind == tyFromExpr and c.inGenericContext > 0: + # don't try to evaluate + discard elif arg.kind != nkEmpty: var evaluated = c.semTryConstExpr(c, arg) if evaluated != nil: @@ -2305,11 +2308,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, a = typ else: if m.callee.kind == tyGenericBody: - # we can't use `makeStaticExpr` if `arg` has a generic type - # because it generates `tyStatic`, which semtypinst doesn't touch - # not sure if checking for `tyFromExpr` is enough - if f.kind == tyStatic and typeRel(m, f.base, a) != isNone and - a.kind != tyFromExpr: + if f.kind == tyStatic and typeRel(m, f.base, a) != isNone: result = makeStaticExpr(m.c, arg) result.typ.flags.incl tfUnresolved result.typ.n = arg 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: |