fixes 'nim check' crash

This commit is contained in:
Araq 2017-03-01 09:57:26 +01:00
commit 936ed9721b

View file

@ -478,7 +478,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
typ = semTypeNode(c, a.sons[length-2], nil) typ = semTypeNode(c, a.sons[length-2], nil)
else: else:
typ = nil typ = nil
var def: PNode var def: PNode = ast.emptyNode
if a.sons[length-1].kind != nkEmpty: if a.sons[length-1].kind != nkEmpty:
def = semExprWithType(c, a.sons[length-1], {efAllowDestructor}) def = semExprWithType(c, a.sons[length-1], {efAllowDestructor})
if def.typ.kind == tyTypeDesc and c.p.owner.kind != skMacro: if def.typ.kind == tyTypeDesc and c.p.owner.kind != skMacro:
@ -500,7 +500,6 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
localError(def.info, errCannotInferTypeOfTheLiteral, localError(def.info, errCannotInferTypeOfTheLiteral,
($typ.kind).substr(2).toLowerAscii) ($typ.kind).substr(2).toLowerAscii)
else: else:
def = ast.emptyNode
if symkind == skLet: localError(a.info, errLetNeedsInit) if symkind == skLet: localError(a.info, errLetNeedsInit)
# this can only happen for errornous var statements: # this can only happen for errornous var statements:
@ -539,7 +538,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
if warnShadowIdent in gNotes and not identWithin(def, v.name): if warnShadowIdent in gNotes and not identWithin(def, v.name):
message(a.info, warnShadowIdent, v.name.s) message(a.info, warnShadowIdent, v.name.s)
if a.kind != nkVarTuple: if a.kind != nkVarTuple:
if def != nil and def.kind != nkEmpty: if def.kind != nkEmpty:
# this is needed for the evaluation pass and for the guard checking: # this is needed for the evaluation pass and for the guard checking:
v.ast = def v.ast = def
if sfThread in v.flags: localError(def.info, errThreadvarCannotInit) if sfThread in v.flags: localError(def.info, errThreadvarCannotInit)