fixes 'nim check' crash

This commit is contained in:
Araq
2017-03-01 09:57:26 +01:00
parent 3d46600a90
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)
else:
typ = nil
var def: PNode
var def: PNode = ast.emptyNode
if a.sons[length-1].kind != nkEmpty:
def = semExprWithType(c, a.sons[length-1], {efAllowDestructor})
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,
($typ.kind).substr(2).toLowerAscii)
else:
def = ast.emptyNode
if symkind == skLet: localError(a.info, errLetNeedsInit)
# 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):
message(a.info, warnShadowIdent, v.name.s)
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:
v.ast = def
if sfThread in v.flags: localError(def.info, errThreadvarCannotInit)