mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
Do not crash while instantiating a generic outside a call (#8279)
Fixes #8270
This commit is contained in:
@@ -569,7 +569,10 @@ proc procParamTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||
# signature. There is a change that the target
|
||||
# type is already fully-determined, so we are
|
||||
# going to try resolve it
|
||||
f = generateTypeInstance(c.c, c.bindings, c.call.info, f)
|
||||
if c.call != nil:
|
||||
f = generateTypeInstance(c.c, c.bindings, c.call.info, f)
|
||||
else:
|
||||
f = nil
|
||||
if f == nil or f.isMetaType:
|
||||
# no luck resolving the type, so the inference fails
|
||||
return isBothMetaConvertible
|
||||
|
||||
7
tests/generics/t8270.nim
Normal file
7
tests/generics/t8270.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
discard """
|
||||
line: 6
|
||||
errormsg: "cannot instantiate: \'T\'"
|
||||
"""
|
||||
|
||||
proc m[T](x: T): int = discard
|
||||
echo [m]
|
||||
Reference in New Issue
Block a user