mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
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)
14 lines
332 B
Nim
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)
|