This commit is contained in:
Araq 2012-01-07 20:30:51 +01:00
commit 7f3b3298b4
3 changed files with 29 additions and 26 deletions

View file

@ -547,10 +547,11 @@ type
proc handleError(msg: TMsgKind, eh: TErrorHandling) = proc handleError(msg: TMsgKind, eh: TErrorHandling) =
if msg == errInternal: if msg == errInternal:
assert(false) # we want a stack trace here assert(false) # we want a stack trace here
if (msg >= fatalMin) and (msg <= fatalMax): if msg >= fatalMin and msg <= fatalMax:
if gVerbosity >= 3: assert(false) if gVerbosity >= 3: assert(false)
quit(1) quit(1)
if (msg >= errMin) and (msg <= errMax): if msg >= errMin and msg <= errMax:
if gVerbosity >= 3: assert(false)
inc(gErrorCounter) inc(gErrorCounter)
options.gExitcode = 1'i8 options.gExitcode = 1'i8
if gErrorCounter >= gErrorMax or eh == doAbort: if gErrorCounter >= gErrorMax or eh == doAbort:

View file

@ -625,14 +625,18 @@ proc semGenericParamInInvokation(c: PContext, n: PNode): PType =
result = semTypeNode(c, n, nil) result = semTypeNode(c, n, nil)
proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
if s.typ == nil or s.typ.kind != tyGenericBody:
GlobalError(n.info, errCannotInstantiateX, s.name.s)
result = newOrPrevType(tyGenericInvokation, prev, c) result = newOrPrevType(tyGenericInvokation, prev, c)
if s.typ.containerID == 0: InternalError(n.info, "semtypes.semGeneric") var isConcrete = true
if sonsLen(n) != sonsLen(s.typ): if s.typ == nil:
GlobalError(n.info, errCannotInstantiateX, s.name.s)
elif s.typ.kind != tyGenericBody:
isConcrete = false
elif s.typ.containerID == 0:
InternalError(n.info, "semtypes.semGeneric")
elif sonsLen(n) != sonsLen(s.typ):
GlobalError(n.info, errWrongNumberOfArguments) GlobalError(n.info, errWrongNumberOfArguments)
addSon(result, s.typ) addSon(result, s.typ)
var isConcrete = true # iterate over arguments: # iterate over arguments:
for i in countup(1, sonsLen(n)-1): for i in countup(1, sonsLen(n)-1):
var elem = semGenericParamInInvokation(c, n.sons[i]) var elem = semGenericParamInInvokation(c, n.sons[i])
if containsGenericType(elem): isConcrete = false if containsGenericType(elem): isConcrete = false

View file

@ -1,28 +1,26 @@
discard """
disabled: true
"""
# Compiles:
type type
TA[T] = object
PA[T] = ref TA[T] PA[T] = ref TA[T]
TA[T] = object
field: T
var a: PA[string] var a: PA[string]
new(a)
a.field = "some string"
# Compiles unless you use var a: PA[string] when false:
type # Compiles unless you use var a: PA[string]
PA = ref TA type
TA[T] = object PA = ref TA
TA[T] = object
# Cannot instantiate: # Cannot instantiate:
type type
TA[T] = object TA[T] = object
a: PA[T] a: PA[T]
PA[T] = ref TA[T] PA[T] = ref TA[T]
type type
PA[T] = ref TA[T] PA[T] = ref TA[T]
TA[T] = object TA[T] = object