This commit is contained in:
Andreas Rumpf 2019-05-22 07:37:25 +02:00 • committed by GitHub
commit 23dbc9ad58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -34,6 +34,15 @@ proc ithField(n: PNode, field: var int): PSym =
else: dec(field) else: dec(field)
else: discard else: discard
proc ithField(t: PType, field: var int): PSym =
var base = t.sons[0]
while base != nil:
let b = skipTypes(base, skipPtrs)
result = ithField(b.n, field)
if result != nil: return result
base = b.sons[0]
result = ithField(t.n, field)
proc annotateType*(n: PNode, t: PType; conf: ConfigRef) = proc annotateType*(n: PNode, t: PType; conf: ConfigRef) =
let x = t.skipTypes(abstractInst+{tyRange}) let x = t.skipTypes(abstractInst+{tyRange})
# Note: x can be unequal to t and we need to be careful to use 't' # Note: x can be unequal to t and we need to be careful to use 't'
@ -44,7 +53,7 @@ proc annotateType*(n: PNode, t: PType; conf: ConfigRef) =
n.typ = t n.typ = t
for i in 1 ..< n.len: for i in 1 ..< n.len:
var j = i-1 var j = i-1
let field = x.n.ithField(j) let field = x.ithField(j)
if field.isNil: if field.isNil:
globalError conf, n.info, "invalid field at index " & $i globalError conf, n.info, "invalid field at index " & $i
else: else:

View file

@ -1782,8 +1782,9 @@ proc getNullValue(typ: PType, info: TLineInfo; conf: ConfigRef): PNode =
# initialize inherited fields: # initialize inherited fields:
var base = t.sons[0] var base = t.sons[0]
while base != nil: while base != nil:
getNullValueAux(skipTypes(base, skipPtrs).n, result, conf) let b = skipTypes(base, skipPtrs)
base = base.sons[0] getNullValueAux(b.n, result, conf)
base = b.sons[0]
getNullValueAux(t.n, result, conf) getNullValueAux(t.n, result, conf)
of tyArray: of tyArray:
result = newNodeIT(nkBracket, info, t) result = newNodeIT(nkBracket, info, t)