Files
Nim/tests/generics/tgenericbodyreturn3.nim
metagn 2f904535d0 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.
2024-10-10 15:35:51 +02: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)