This commit is contained in:
Araq
2017-11-22 23:39:50 +01:00
parent 2f17be9c22
commit a6226d9452
4 changed files with 35 additions and 2 deletions

View File

@@ -1448,6 +1448,10 @@ proc rawAddSon*(father, son: PType) =
add(father.sons, son)
if not son.isNil: propagateToOwner(father, son)
proc rawAddSonNoPropagationOfTypeFlags*(father, son: PType) =
if isNil(father.sons): father.sons = @[]
add(father.sons, son)
proc addSonNilAllowed*(father, son: PNode) =
if isNil(father.sons): father.sons = @[]
add(father.sons, son)

View File

@@ -296,7 +296,9 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
base = semTypeNode(c, n.sons[2], nil)
# ensure we only construct a tyArray when there was no error (bug #3048):
result = newOrPrevType(tyArray, prev, c)
addSonSkipIntLit(result, indx)
# bug #6682: Do not propagate initialization requirements etc for the
# index type:
rawAddSonNoPropagationOfTypeFlags(result, indx)
addSonSkipIntLit(result, base)
else:
localError(n.info, errArrayExpectsTwoTypeParams)

View File

@@ -522,7 +522,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
if r2.kind in {tyPtr, tyRef}:
r = skipTypes(r2, {tyPtr, tyRef})
result.sons[i] = r
propagateToOwner(result, r)
#if result.kind != tyArray or i != 0:
# propagateToOwner(result, r)
# bug #4677: Do not instantiate effect lists
result.n = replaceTypeVarsN(cl, result.n, ord(result.kind==tyProc))
case result.kind

View File

@@ -0,0 +1,26 @@
discard """
output: '''success'''
"""
# bug #6682
type
Fields = enum
A=1, B, C
Obj = object
fld: array[Fields, int]
AsGeneric[T] = array[Fields, T]
Obj2[T] = object
fld: AsGeneric[T]
var a: Obj # this works
var arr: array[Fields, int]
var b = Obj() # this doesn't (also doesn't works with additional fields)
var z = Obj2[int]()
echo "success"