This commit is contained in:
Araq 2017-12-29 20:01:49 +01:00
commit cf259fbd1c
2 changed files with 4 additions and 3 deletions

View file

@ -719,6 +719,7 @@ proc gcase(g: var TSrcGen, n: PNode) =
var c: TContext var c: TContext
initContext(c) initContext(c)
var length = sonsLen(n) var length = sonsLen(n)
if length == 0: return
var last = if n.sons[length-1].kind == nkElse: -2 else: -1 var last = if n.sons[length-1].kind == nkElse: -2 else: -1
if longMode(g, n, 0, last): incl(c.flags, rfLongMode) if longMode(g, n, 0, last): incl(c.flags, rfLongMode)
putWithSpace(g, tkCase, "case") putWithSpace(g, tkCase, "case")

View file

@ -74,7 +74,7 @@ proc fitNode(c: PContext, formal: PType, arg: PNode; info: TLineInfo): PNode =
localError(arg.info, errExprXHasNoType, localError(arg.info, errExprXHasNoType,
renderTree(arg, {renderNoComments})) renderTree(arg, {renderNoComments}))
# error correction: # error correction:
result = copyNode(arg) result = copyTree(arg)
result.typ = formal result.typ = formal
else: else:
result = indexTypesMatch(c, formal, arg.typ, arg) result = indexTypesMatch(c, formal, arg.typ, arg)
@ -168,9 +168,9 @@ proc commonType*(x, y: PType): PType =
proc endsInNoReturn(n: PNode): bool = proc endsInNoReturn(n: PNode): bool =
# check if expr ends in raise exception or call of noreturn proc # check if expr ends in raise exception or call of noreturn proc
var it = n var it = n
while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0: while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0:
it = it.lastSon it = it.lastSon
result = it.kind == nkRaiseStmt or result = it.kind == nkRaiseStmt or
it.kind in nkCallKinds and it[0].kind == nkSym and sfNoReturn in it[0].sym.flags it.kind in nkCallKinds and it[0].kind == nkSym and sfNoReturn in it[0].sym.flags
proc commonType*(x: PType, y: PNode): PType = proc commonType*(x: PType, y: PNode): PType =