Do not crash while instantiating a generic outside a call (#8279)
Fixes #8270
This commit is contained in:
parent
dd47013017
commit
9b98add6c7
2 changed files with 11 additions and 1 deletions
|
|
@ -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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue