diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semmacrosanity.nim | 11 | ||||
-rw-r--r-- | compiler/vmgen.nim | 5 |
2 files changed, 13 insertions, 3 deletions
diff --git a/compiler/semmacrosanity.nim b/compiler/semmacrosanity.nim index 02c6c86e6..faf3e3868 100644 --- a/compiler/semmacrosanity.nim +++ b/compiler/semmacrosanity.nim @@ -34,6 +34,15 @@ proc ithField(n: PNode, field: var int): PSym = else: dec(field) 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) = let x = t.skipTypes(abstractInst+{tyRange}) # 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 for i in 1 ..< n.len: var j = i-1 - let field = x.n.ithField(j) + let field = x.ithField(j) if field.isNil: globalError conf, n.info, "invalid field at index " & $i else: diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 890f28065..6fe51dba6 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1782,8 +1782,9 @@ proc getNullValue(typ: PType, info: TLineInfo; conf: ConfigRef): PNode = # initialize inherited fields: var base = t.sons[0] while base != nil: - getNullValueAux(skipTypes(base, skipPtrs).n, result, conf) - base = base.sons[0] + let b = skipTypes(base, skipPtrs) + getNullValueAux(b.n, result, conf) + base = b.sons[0] getNullValueAux(t.n, result, conf) of tyArray: result = newNodeIT(nkBracket, info, t) |