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
parent dd47013017
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
# 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
View File

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