fixes #33
This commit is contained in:
parent
7405278138
commit
7f3b3298b4
3 changed files with 29 additions and 26 deletions
|
|
@ -547,10 +547,11 @@ type
|
|||
proc handleError(msg: TMsgKind, eh: TErrorHandling) =
|
||||
if msg == errInternal:
|
||||
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)
|
||||
quit(1)
|
||||
if (msg >= errMin) and (msg <= errMax):
|
||||
if msg >= errMin and msg <= errMax:
|
||||
if gVerbosity >= 3: assert(false)
|
||||
inc(gErrorCounter)
|
||||
options.gExitcode = 1'i8
|
||||
if gErrorCounter >= gErrorMax or eh == doAbort:
|
||||
|
|
|
|||
|
|
@ -625,14 +625,18 @@ 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 or s.typ.kind != tyGenericBody:
|
||||
GlobalError(n.info, errCannotInstantiateX, s.name.s)
|
||||
result = newOrPrevType(tyGenericInvokation, prev, c)
|
||||
if s.typ.containerID == 0: InternalError(n.info, "semtypes.semGeneric")
|
||||
if sonsLen(n) != sonsLen(s.typ):
|
||||
var isConcrete = true
|
||||
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)
|
||||
addSon(result, s.typ)
|
||||
var isConcrete = true # iterate over arguments:
|
||||
# iterate over arguments:
|
||||
for i in countup(1, sonsLen(n)-1):
|
||||
var elem = semGenericParamInInvokation(c, n.sons[i])
|
||||
if containsGenericType(elem): isConcrete = false
|
||||
|
|
|
|||
|
|
@ -1,28 +1,26 @@
|
|||
discard """
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
# Compiles:
|
||||
|
||||
type
|
||||
TA[T] = object
|
||||
PA[T] = ref TA[T]
|
||||
TA[T] = object
|
||||
field: T
|
||||
var a: PA[string]
|
||||
new(a)
|
||||
a.field = "some string"
|
||||
|
||||
# Compiles unless you use var a: PA[string]
|
||||
type
|
||||
PA = ref TA
|
||||
TA[T] = object
|
||||
when false:
|
||||
# Compiles unless you use var a: PA[string]
|
||||
type
|
||||
PA = ref TA
|
||||
TA[T] = object
|
||||
|
||||
|
||||
# Cannot instantiate:
|
||||
type
|
||||
TA[T] = object
|
||||
a: PA[T]
|
||||
PA[T] = ref TA[T]
|
||||
# Cannot instantiate:
|
||||
type
|
||||
TA[T] = object
|
||||
a: PA[T]
|
||||
PA[T] = ref TA[T]
|
||||
|
||||
type
|
||||
PA[T] = ref TA[T]
|
||||
TA[T] = object
|
||||
type
|
||||
PA[T] = ref TA[T]
|
||||
TA[T] = object
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue