make case-object transitions explicit, make unknownLineInfo a const, replace a few magic numbers with consts (#13170)
This commit is contained in:
parent
2bf337abae
commit
796aafe7e0
35 changed files with 182 additions and 203 deletions
|
|
@ -129,7 +129,7 @@ proc fixNilType(c: PContext; n: PNode) =
|
|||
if n.kind != nkNilLit and n.typ != nil:
|
||||
localError(c.config, n.info, errDiscardValueX % n.typ.typeToString)
|
||||
elif n.kind in {nkStmtList, nkStmtListExpr}:
|
||||
n.kind = nkStmtList
|
||||
n.transitionSonsKind(nkStmtList)
|
||||
for it in n: fixNilType(c, it)
|
||||
n.typ = nil
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ proc semIf(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
|||
if isEmptyType(typ) or typ.kind in {tyNil, tyUntyped} or
|
||||
(not hasElse and efInTypeof notin flags):
|
||||
for it in n: discardCheck(c, it.lastSon, flags)
|
||||
result.kind = nkIfStmt
|
||||
result.transitionSonsKind(nkIfStmt)
|
||||
# propagate any enforced VoidContext:
|
||||
if typ == c.enforceVoidContext: result.typ = c.enforceVoidContext
|
||||
else:
|
||||
|
|
@ -180,7 +180,7 @@ proc semIf(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
|||
let j = it.len-1
|
||||
if not endsInNoReturn(it[j]):
|
||||
it[j] = fitNode(c, typ, it[j], it[j].info)
|
||||
result.kind = nkIfExpr
|
||||
result.transitionSonsKind(nkIfExpr)
|
||||
result.typ = typ
|
||||
|
||||
proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
||||
|
|
@ -867,7 +867,7 @@ proc semFor(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
|||
call[0].sym.magic in {mFields, mFieldPairs, mOmpParFor}:
|
||||
if call[0].sym.magic == mOmpParFor:
|
||||
result = semForVars(c, n, flags)
|
||||
result.kind = nkParForStmt
|
||||
result.transitionSonsKind(nkParForStmt)
|
||||
else:
|
||||
result = semForFields(c, n, call[0].sym.magic)
|
||||
elif isCallExpr and isClosureIterator(call[0].typ.skipTypes(abstractInst)):
|
||||
|
|
@ -1970,7 +1970,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
|||
if n[patternPos].kind != nkEmpty:
|
||||
c.patterns.add(s)
|
||||
if isAnon:
|
||||
n.kind = nkLambda
|
||||
n.transitionSonsKind(nkLambda)
|
||||
result.typ = s.typ
|
||||
if optOwnedRefs in c.config.globalOptions:
|
||||
result.typ = makeVarType(c, result.typ, tyOwned)
|
||||
|
|
@ -1989,7 +1989,7 @@ proc semIterator(c: PContext, n: PNode): PNode =
|
|||
if n[namePos].kind == nkSym:
|
||||
# gensym'ed iterators might need to become closure iterators:
|
||||
n[namePos].sym.owner = getCurrOwner(c)
|
||||
n[namePos].sym.kind = skIterator
|
||||
n[namePos].sym.transitionRoutineSymKind(skIterator)
|
||||
result = semProcAux(c, n, skIterator, iteratorPragmas)
|
||||
# bug #7093: if after a macro transformation we don't have an
|
||||
# nkIteratorDef aynmore, return. The iterator then might have been
|
||||
|
|
@ -2166,7 +2166,7 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
const
|
||||
LastBlockStmts = {nkRaiseStmt, nkReturnStmt, nkBreakStmt, nkContinueStmt}
|
||||
result = n
|
||||
result.kind = nkStmtList
|
||||
result.transitionSonsKind(nkStmtList)
|
||||
var voidContext = false
|
||||
var last = n.len-1
|
||||
# by not allowing for nkCommentStmt etc. we ensure nkStmtListExpr actually
|
||||
|
|
@ -2203,12 +2203,12 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
n.typ = c.enforceVoidContext
|
||||
if i == last and (n.len == 1 or ({efWantValue, efInTypeof} * flags != {})):
|
||||
n.typ = n[i].typ
|
||||
if not isEmptyType(n.typ): n.kind = nkStmtListExpr
|
||||
if not isEmptyType(n.typ): n.transitionSonsKind(nkStmtListExpr)
|
||||
elif i != last or voidContext:
|
||||
discardCheck(c, n[i], flags)
|
||||
else:
|
||||
n.typ = n[i].typ
|
||||
if not isEmptyType(n.typ): n.kind = nkStmtListExpr
|
||||
if not isEmptyType(n.typ): n.transitionSonsKind(nkStmtListExpr)
|
||||
if n[i].kind in LastBlockStmts or
|
||||
n[i].kind in nkCallKinds and n[i][0].kind == nkSym and
|
||||
sfNoReturn in n[i][0].sym.flags:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue