fixes #4898
This commit is contained in:
parent
6ba9c2b119
commit
c1d061bb5a
1 changed files with 10 additions and 3 deletions
|
|
@ -499,6 +499,13 @@ proc fillPartialObject(c: PContext; n: PNode; typ: PType) =
|
||||||
else:
|
else:
|
||||||
localError(n.info, "nkDotNode requires 2 children")
|
localError(n.info, "nkDotNode requires 2 children")
|
||||||
|
|
||||||
|
proc setVarType(v: PSym, typ: PType) =
|
||||||
|
if v.typ != nil and not sameTypeOrNil(v.typ, typ):
|
||||||
|
localError(v.info, "inconsistent typing for reintroduced symbol '" &
|
||||||
|
v.name.s & "': previous type was: " & typeToString(v.typ) &
|
||||||
|
"; new type is: " & typeToString(typ))
|
||||||
|
v.typ = typ
|
||||||
|
|
||||||
proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
var b: PNode
|
var b: PNode
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
|
|
@ -588,7 +595,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
# 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)
|
||||||
v.typ = typ
|
setVarType(v, typ)
|
||||||
b = newNodeI(nkIdentDefs, a.info)
|
b = newNodeI(nkIdentDefs, a.info)
|
||||||
if importantComments():
|
if importantComments():
|
||||||
# keep documentation information:
|
# keep documentation information:
|
||||||
|
|
@ -599,7 +606,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
addToVarSection(c, result, n, b)
|
addToVarSection(c, result, n, b)
|
||||||
else:
|
else:
|
||||||
if def.kind == nkPar: v.ast = def[j]
|
if def.kind == nkPar: v.ast = def[j]
|
||||||
v.typ = tup.sons[j]
|
setVarType(v, tup.sons[j])
|
||||||
b.sons[j] = newSymNode(v)
|
b.sons[j] = newSymNode(v)
|
||||||
addDefer(c, result, v)
|
addDefer(c, result, v)
|
||||||
checkNilable(v)
|
checkNilable(v)
|
||||||
|
|
@ -633,7 +640,7 @@ proc semConst(c: PContext, n: PNode): PNode =
|
||||||
if typeAllowed(typ, skConst) != nil and def.kind != nkNilLit:
|
if typeAllowed(typ, skConst) != nil and def.kind != nkNilLit:
|
||||||
localError(a.info, "invalid type for const: " & typeToString(typ))
|
localError(a.info, "invalid type for const: " & typeToString(typ))
|
||||||
continue
|
continue
|
||||||
v.typ = typ
|
setVarType(v, typ)
|
||||||
v.ast = def # no need to copy
|
v.ast = def # no need to copy
|
||||||
if sfGenSym notin v.flags: addInterfaceDecl(c, v)
|
if sfGenSym notin v.flags: addInterfaceDecl(c, v)
|
||||||
var b = newNodeI(nkConstDef, a.info)
|
var b = newNodeI(nkConstDef, a.info)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue