diff options
author | Zahary Karadjov <zahary@gmail.com> | 2014-03-16 21:44:21 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2014-03-16 21:44:21 +0200 |
commit | b3da0ab88824c0f59f8f6829d1641aebbc82042b (patch) | |
tree | 699520b0404b80638e235b929bc6757b2ccf3028 /compiler | |
parent | 26890b6525f12f89c2a93c1cde1c444e6af2e9d7 (diff) | |
download | Nim-b3da0ab88824c0f59f8f6829d1641aebbc82042b.tar.gz |
fix #1007
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semtypes.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 06fcd74b4..2f1532e6a 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -945,6 +945,11 @@ proc semGenericParamInInvokation(c: PContext, n: PNode): PType = result = semTypeNode(c, n, nil) proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = + if s.typ == nil: + localError(n.info, "cannot instantiate the '$1' $2" % + [s.name.s, ($s.kind).substr(2).toLower]) + return newOrPrevType(tyError, prev, c) + result = newOrPrevType(tyGenericInvokation, prev, c) addSonSkipIntLit(result, s.typ) @@ -954,17 +959,13 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = rawAddSon(result, typ) else: addSonSkipIntLit(result, typ) - if s.typ == nil: - localError(n.info, errCannotInstantiateX, s.name.s) - return newOrPrevType(tyError, prev, c) - elif s.typ.kind == tyForward: + if s.typ.kind == tyForward: for i in countup(1, sonsLen(n)-1): var elem = semGenericParamInInvokation(c, n.sons[i]) addToResult(elem) elif s.typ.kind != tyGenericBody: #we likely got code of the form TypeA[TypeB] where TypeA is #not generic. - debug s.typ localError(n.info, errNoGenericParamsAllowedForX, s.name.s) return newOrPrevType(tyError, prev, c) else: |