Files
Nim/tests/generics/tgenericbodyreturn3.nim
metagn d102571d78 don't allow instantiations resolving to generic body types (#24273)
fixes #24091, refs #24092

Any instantiations resolving to a generic body type now gives an error.
Due to #24092, this does not error in cases like matching against `type
M` in generics because generic body type symbols are just not
instantiated. But this prevents parameters with type `type M` from being
used, although there doesn't seem to be any code which does this. Just
in case such code exists, we still allow `typedesc` types resolving to
generic body types.

(cherry picked from commit 2f904535d0)
2025-01-14 07:33:27 +01:00

14 lines
332 B
Nim

discard """
errormsg: "cannot instantiate: 'ShouldNotResolve'"
"""
# issue #24091
type Generic[U] = object
proc foo[ShouldNotResolve](x: typedesc[ShouldNotResolve]): ShouldNotResolve =
echo ShouldNotResolve # Generic
echo declared(result) # true
echo typeof(result) # Generic
echo typeof(foo(Generic)) # void
foo(Generic)