mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-31 02:43:41 +00:00
fixes #6682
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
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"
|
||||
Reference in New Issue
Block a user