Do not crash while instantiating a generic outside a call (#8279)

Fixes #8270
This commit is contained in:
LemonBoy 2018-07-14 01:44:40 +02:00 • committed by Andreas Rumpf
commit 9b98add6c7
2 changed files with 11 additions and 1 deletions

View file

@ -569,7 +569,10 @@ proc procParamTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
# signature. There is a change that the target # signature. There is a change that the target
# type is already fully-determined, so we are # type is already fully-determined, so we are
# going to try resolve it # going to try resolve it
if c.call != nil:
f = generateTypeInstance(c.c, c.bindings, c.call.info, f) f = generateTypeInstance(c.c, c.bindings, c.call.info, f)
else:
f = nil
if f == nil or f.isMetaType: if f == nil or f.isMetaType:
# no luck resolving the type, so the inference fails # no luck resolving the type, so the inference fails
return isBothMetaConvertible return isBothMetaConvertible

7
tests/generics/t8270.nim Normal file
View file

@ -0,0 +1,7 @@
discard """
line: 6
errormsg: "cannot instantiate: \'T\'"
"""
proc m[T](x: T): int = discard
echo [m]