fix #988
trivial crash caused due to unchecked iteration over an empty reclist
This commit is contained in:
parent
d5798b43de
commit
85fe5e1940
2 changed files with 6 additions and 6 deletions
|
|
@ -931,7 +931,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
var ty = n.sons[0].typ
|
var ty = n.sons[0].typ
|
||||||
var f: PSym = nil
|
var f: PSym = nil
|
||||||
result = nil
|
result = nil
|
||||||
if isTypeExpr(n.sons[0]) or ty.kind == tyTypeDesc and ty.base.kind != tyNone:
|
if isTypeExpr(n.sons[0]) or (ty.kind == tyTypeDesc and ty.base.kind != tyNone):
|
||||||
if ty.kind == tyTypeDesc: ty = ty.base
|
if ty.kind == tyTypeDesc: ty = ty.base
|
||||||
case ty.kind
|
case ty.kind
|
||||||
of tyEnum:
|
of tyEnum:
|
||||||
|
|
@ -950,7 +950,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
return readTypeParameter(c, ty, i, n.info)
|
return readTypeParameter(c, ty, i, n.info)
|
||||||
of tyObject, tyTuple:
|
of tyObject, tyTuple:
|
||||||
if ty.n.kind == nkRecList:
|
if ty.n.kind == nkRecList:
|
||||||
for field in ty.n.sons:
|
for field in ty.n:
|
||||||
if field.sym.name == i:
|
if field.sym.name == i:
|
||||||
n.typ = newTypeWithSons(c, tyFieldAccessor, @[ty, field.sym.typ])
|
n.typ = newTypeWithSons(c, tyFieldAccessor, @[ty, field.sym.typ])
|
||||||
n.typ.n = copyTree(n)
|
n.typ.n = copyTree(n)
|
||||||
|
|
@ -962,6 +962,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
# XXX: This is probably not relevant any more
|
# XXX: This is probably not relevant any more
|
||||||
# reset to prevent 'nil' bug: see "tests/reject/tenumitems.nim":
|
# reset to prevent 'nil' bug: see "tests/reject/tenumitems.nim":
|
||||||
ty = n.sons[0].typ
|
ty = n.sons[0].typ
|
||||||
|
return nil
|
||||||
|
|
||||||
ty = skipTypes(ty, {tyGenericInst, tyVar, tyPtr, tyRef})
|
ty = skipTypes(ty, {tyGenericInst, tyVar, tyPtr, tyRef})
|
||||||
var check: PNode = nil
|
var check: PNode = nil
|
||||||
|
|
|
||||||
|
|
@ -320,9 +320,8 @@ proc propagateFieldFlags(t: PType, n: PNode) =
|
||||||
of nkSym:
|
of nkSym:
|
||||||
propagateToOwner(t, n.sym.typ)
|
propagateToOwner(t, n.sym.typ)
|
||||||
of nkRecList, nkRecCase, nkOfBranch, nkElse:
|
of nkRecList, nkRecCase, nkOfBranch, nkElse:
|
||||||
if n.sons != nil:
|
for son in n:
|
||||||
for son in n.sons:
|
propagateFieldFlags(t, son)
|
||||||
propagateFieldFlags(t, son)
|
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue