mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
forbides adding sons for PType (#23030)
I image `add` for `PType` to be used everythere
This commit is contained in:
@@ -1567,10 +1567,6 @@ when false:
|
||||
result = prev
|
||||
result.sons = sons
|
||||
|
||||
proc addSon*(father, son: PType) =
|
||||
# todo fixme: in IC, `son` might be nil
|
||||
father.sons.add(son)
|
||||
|
||||
proc mergeLoc(a: var TLoc, b: TLoc) =
|
||||
if a.k == low(typeof(a.k)): a.k = b.k
|
||||
if a.storage == low(typeof(a.storage)): a.storage = b.storage
|
||||
@@ -1713,9 +1709,6 @@ proc rawAddSon*(father, son: PType; propagateHasAsgn = true) =
|
||||
father.sons.add(son)
|
||||
if not son.isNil: propagateToOwner(father, son, propagateHasAsgn)
|
||||
|
||||
proc rawAddSonNoPropagationOfTypeFlags*(father, son: PType) =
|
||||
father.sons.add(son)
|
||||
|
||||
proc addSonNilAllowed*(father, son: PNode) =
|
||||
father.sons.add(son)
|
||||
|
||||
|
||||
@@ -994,8 +994,10 @@ proc typeBodyFromPacked(c: var PackedDecoder; g: var PackedModuleGraph;
|
||||
for op, item in pairs t.attachedOps:
|
||||
result.attachedOps[op] = loadSym(c, g, si, item)
|
||||
result.typeInst = loadType(c, g, si, t.typeInst)
|
||||
var sons = newSeq[PType]()
|
||||
for son in items t.types:
|
||||
result.addSon loadType(c, g, si, son)
|
||||
sons.add loadType(c, g, si, son)
|
||||
result.setSons(sons)
|
||||
loadAstBody(t, n)
|
||||
when false:
|
||||
for gen, id in items t.methods:
|
||||
|
||||
@@ -345,10 +345,9 @@ proc semConv(c: PContext, n: PNode; flags: TExprFlags = {}, expectedType: PType
|
||||
|
||||
if targetType.kind in {tySink, tyLent} or isOwnedSym(c, n[0]):
|
||||
let baseType = semTypeNode(c, n[1], nil).skipTypes({tyTypeDesc})
|
||||
let t = newTypeS(targetType.kind, c)
|
||||
let t = newTypeS(targetType.kind, c, @[baseType])
|
||||
if targetType.kind == tyOwned:
|
||||
t.flags.incl tfHasOwned
|
||||
t.rawAddSonNoPropagationOfTypeFlags baseType
|
||||
result = newNodeI(nkType, n.info)
|
||||
result.typ = makeTypeDesc(c, t)
|
||||
return
|
||||
|
||||
@@ -424,10 +424,9 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
|
||||
typeToString(indxB.skipTypes({tyRange})))
|
||||
base = semTypeNode(c, n[2], nil)
|
||||
# ensure we only construct a tyArray when there was no error (bug #3048):
|
||||
result = newOrPrevType(tyArray, prev, c)
|
||||
# bug #6682: Do not propagate initialization requirements etc for the
|
||||
# index type:
|
||||
rawAddSonNoPropagationOfTypeFlags(result, indx)
|
||||
result = newOrPrevType(tyArray, prev, c, @[indx])
|
||||
addSonSkipIntLit(result, base, c.idgen)
|
||||
else:
|
||||
localError(c.config, n.info, errArrayExpectsTwoTypeParams)
|
||||
@@ -1019,13 +1018,11 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||
case wrapperKind
|
||||
of tyOwned:
|
||||
if optOwnedRefs in c.config.globalOptions:
|
||||
let t = newTypeS(tyOwned, c)
|
||||
let t = newTypeS(tyOwned, c, @[result])
|
||||
t.flags.incl tfHasOwned
|
||||
t.rawAddSonNoPropagationOfTypeFlags result
|
||||
result = t
|
||||
of tySink:
|
||||
let t = newTypeS(tySink, c)
|
||||
t.rawAddSonNoPropagationOfTypeFlags result
|
||||
let t = newTypeS(tySink, c, @[result])
|
||||
result = t
|
||||
else: discard
|
||||
if result.kind == tyRef and c.config.selectedGC in {gcArc, gcOrc, gcAtomicArc}:
|
||||
|
||||
Reference in New Issue
Block a user