fixes #6682
This commit is contained in:
parent
2f17be9c22
commit
a6226d9452
4 changed files with 35 additions and 2 deletions
|
|
@ -1448,6 +1448,10 @@ proc rawAddSon*(father, son: PType) =
|
||||||
add(father.sons, son)
|
add(father.sons, son)
|
||||||
if not son.isNil: propagateToOwner(father, 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) =
|
proc addSonNilAllowed*(father, son: PNode) =
|
||||||
if isNil(father.sons): father.sons = @[]
|
if isNil(father.sons): father.sons = @[]
|
||||||
add(father.sons, son)
|
add(father.sons, son)
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,9 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
|
||||||
base = semTypeNode(c, n.sons[2], nil)
|
base = semTypeNode(c, n.sons[2], nil)
|
||||||
# ensure we only construct a tyArray when there was no error (bug #3048):
|
# ensure we only construct a tyArray when there was no error (bug #3048):
|
||||||
result = newOrPrevType(tyArray, prev, c)
|
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)
|
addSonSkipIntLit(result, base)
|
||||||
else:
|
else:
|
||||||
localError(n.info, errArrayExpectsTwoTypeParams)
|
localError(n.info, errArrayExpectsTwoTypeParams)
|
||||||
|
|
|
||||||
|
|
@ -522,7 +522,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
if r2.kind in {tyPtr, tyRef}:
|
if r2.kind in {tyPtr, tyRef}:
|
||||||
r = skipTypes(r2, {tyPtr, tyRef})
|
r = skipTypes(r2, {tyPtr, tyRef})
|
||||||
result.sons[i] = r
|
result.sons[i] = r
|
||||||
propagateToOwner(result, r)
|
#if result.kind != tyArray or i != 0:
|
||||||
|
# propagateToOwner(result, r)
|
||||||
# bug #4677: Do not instantiate effect lists
|
# bug #4677: Do not instantiate effect lists
|
||||||
result.n = replaceTypeVarsN(cl, result.n, ord(result.kind==tyProc))
|
result.n = replaceTypeVarsN(cl, result.n, ord(result.kind==tyProc))
|
||||||
case result.kind
|
case result.kind
|
||||||
|
|
|
||||||
26
tests/notnil/tmust_compile.nim
Normal file
26
tests/notnil/tmust_compile.nim
Normal 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"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue