'nil' as a statement is deprecated, use an empty 'discard' instead

This commit is contained in:
Araq 2014-01-19 16:54:59 +01:00
commit 73c6efdf66
54 changed files with 170 additions and 170 deletions

View file

@ -54,7 +54,7 @@ proc isPartOfAux(a, b: PType, marker: var TIntSet): TAnalysisResult =
for i in countup(0, sonsLen(a) - 1): for i in countup(0, sonsLen(a) - 1):
result = isPartOfAux(a.sons[i], b, marker) result = isPartOfAux(a.sons[i], b, marker)
if result == arYes: return if result == arYes: return
else: nil else: discard
proc isPartOf(a, b: PType): TAnalysisResult = proc isPartOf(a, b: PType): TAnalysisResult =
## checks iff 'a' can be part of 'b'. Iterates over VALUE types! ## checks iff 'a' can be part of 'b'. Iterates over VALUE types!
@ -140,7 +140,7 @@ proc isPartOf*(a, b: PNode): TAnalysisResult =
result = isPartOf(a[1], b[1]) result = isPartOf(a[1], b[1])
of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr: of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr:
result = isPartOf(a[0], b[0]) result = isPartOf(a[0], b[0])
else: nil else: discard
# Calls return a new location, so a default of ``arNo`` is fine. # Calls return a new location, so a default of ``arNo`` is fine.
else: else:
# go down recursively; this is quite demanding: # go down recursively; this is quite demanding:
@ -177,6 +177,6 @@ proc isPartOf*(a, b: PNode): TAnalysisResult =
if isPartOf(a.typ, b.typ) != arNo: if isPartOf(a.typ, b.typ) != arNo:
result = isPartOf(a[0], b) result = isPartOf(a[0], b)
if result == arNo: result = arMaybe if result == arNo: result = arMaybe
else: nil else: discard
else: nil else: discard

View file

@ -1257,7 +1257,7 @@ proc propagateToOwner*(owner, elem: PType) =
owner.flags.incl tfNeedsInit owner.flags.incl tfNeedsInit
if tfNeedsInit in elem.flags: if tfNeedsInit in elem.flags:
if owner.kind in HaveTheirOwnEmpty: nil if owner.kind in HaveTheirOwnEmpty: discard
else: owner.flags.incl tfNeedsInit else: owner.flags.incl tfNeedsInit
if tfShared in elem.flags: if tfShared in elem.flags:

View file

@ -73,7 +73,7 @@ proc isInCurrentFrame(p: BProc, n: PNode): bool =
result = false result = false
of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr: of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr:
result = isInCurrentFrame(p, n.sons[0]) result = isInCurrentFrame(p, n.sons[0])
else: nil else: discard
proc openArrayLoc(p: BProc, n: PNode): PRope = proc openArrayLoc(p: BProc, n: PNode): PRope =
var a: TLoc var a: TLoc

View file

@ -202,7 +202,7 @@ proc asgnComplexity(n: PNode): int =
of nkRecList: of nkRecList:
for t in items(n): for t in items(n):
result += asgnComplexity(t) result += asgnComplexity(t)
else: nil else: discard
proc optAsgnLoc(a: TLoc, t: PType, field: PRope): TLoc = proc optAsgnLoc(a: TLoc, t: PType, field: PRope): TLoc =
result.k = locField result.k = locField
@ -228,7 +228,7 @@ proc genOptAsgnObject(p: BProc, dest, src: TLoc, flags: TAssignmentFlags,
optAsgnLoc(src, field.typ, field.loc.r), flags) optAsgnLoc(src, field.typ, field.loc.r), flags)
of nkRecList: of nkRecList:
for child in items(t): genOptAsgnObject(p, dest, src, flags, child) for child in items(t): genOptAsgnObject(p, dest, src, flags, child)
else: nil else: discard
proc genGenericAsgn(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = proc genGenericAsgn(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) =
# Consider: # Consider:
@ -1901,7 +1901,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
of nkClosure: genClosure(p, n, d) of nkClosure: genClosure(p, n, d)
of nkMetaNode: expr(p, n.sons[0], d) of nkMetaNode: expr(p, n.sons[0], d)
of nkEmpty: nil of nkEmpty: discard
of nkWhileStmt: genWhileStmt(p, n) of nkWhileStmt: genWhileStmt(p, n)
of nkVarSection, nkLetSection: genVarStmt(p, n) of nkVarSection, nkLetSection: genVarStmt(p, n)
of nkConstSection: genConstStmt(p, n) of nkConstSection: genConstStmt(p, n)
@ -1931,7 +1931,7 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
of nkCommentStmt, nkIteratorDef, nkIncludeStmt, of nkCommentStmt, nkIteratorDef, nkIncludeStmt,
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt, nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
nkFromStmt, nkTemplateDef, nkMacroDef: nkFromStmt, nkTemplateDef, nkMacroDef:
nil discard
of nkPragma: genPragma(p, n) of nkPragma: genPragma(p, n)
of nkProcDef, nkMethodDef, nkConverterDef: of nkProcDef, nkMethodDef, nkConverterDef:
if (n.sons[genericParamsPos].kind == nkEmpty): if (n.sons[genericParamsPos].kind == nkEmpty):

View file

@ -285,7 +285,7 @@ proc readMergeSections(cfilename: string, m: var TMergeSections) =
withCFile(cfilename): withCFile(cfilename):
readKey(L, k) readKey(L, k)
if k == "NIM_merge_INFO": if k == "NIM_merge_INFO":
nil discard
elif ^L.bufpos == '*' and ^(L.bufpos+1) == '/': elif ^L.bufpos == '*' and ^(L.bufpos+1) == '/':
inc(L.bufpos, 2) inc(L.bufpos, 2)
# read back into section # read back into section

View file

@ -83,7 +83,7 @@ proc genTraverseProc(c: var TTraversalClosure, accessor: PRope, typ: PType) =
if typ.callConv == ccClosure: if typ.callConv == ccClosure:
lineCg(p, cpsStmts, c.visitorFrmt, rfmt(nil, "$1.ClEnv", accessor)) lineCg(p, cpsStmts, c.visitorFrmt, rfmt(nil, "$1.ClEnv", accessor))
else: else:
nil discard
proc genTraverseProcSeq(c: var TTraversalClosure, accessor: PRope, typ: PType) = proc genTraverseProcSeq(c: var TTraversalClosure, accessor: PRope, typ: PType) =
var p = c.p var p = c.p

View file

@ -25,7 +25,7 @@ proc mangleField(name: string): string =
of 'A'..'Z': of 'A'..'Z':
add(result, chr(ord(name[i]) - ord('A') + ord('a'))) add(result, chr(ord(name[i]) - ord('A') + ord('a')))
of '_': of '_':
nil discard
of 'a'..'z', '0'..'9': of 'a'..'z', '0'..'9':
add(result, name[i]) add(result, name[i])
else: else:
@ -48,7 +48,7 @@ proc mangle(name: string): string =
of 'A'..'Z': of 'A'..'Z':
add(result, chr(ord(name[i]) - ord('A') + ord('a'))) add(result, chr(ord(name[i]) - ord('A') + ord('a')))
of '_': of '_':
nil discard
of 'a'..'z', '0'..'9': of 'a'..'z', '0'..'9':
add(result, name[i]) add(result, name[i])
else: else:

View file

@ -319,7 +319,7 @@ proc genObjectInit(p: BProc, section: TCProcSection, t: PType, a: TLoc,
takeAddr: bool) = takeAddr: bool) =
case analyseObjectWithTypeField(t) case analyseObjectWithTypeField(t)
of frNone: of frNone:
nil discard
of frHeader: of frHeader:
var r = rdLoc(a) var r = rdLoc(a)
if not takeAddr: r = ropef("(*$1)", [r]) if not takeAddr: r = ropef("(*$1)", [r])
@ -832,7 +832,7 @@ proc genProcNoForward(m: BModule, prc: PSym) =
discard cgsym(m, prc.name.s) discard cgsym(m, prc.name.s)
return return
genProcPrototype(m, prc) genProcPrototype(m, prc)
if lfNoDecl in prc.loc.flags: nil if lfNoDecl in prc.loc.flags: discard
elif prc.typ.callConv == ccInline: elif prc.typ.callConv == ccInline:
# We add inline procs to the calling module to enable C based inlining. # We add inline procs to the calling module to enable C based inlining.
# This also means that a check with ``q.declaredThings`` is wrong, we need # This also means that a check with ``q.declaredThings`` is wrong, we need

View file

@ -66,7 +66,7 @@ proc sameMethodBucket(a, b: PSym): bool =
if sameType(aa, bb) or if sameType(aa, bb) or
(aa.kind == tyObject) and (bb.kind == tyObject) and (aa.kind == tyObject) and (bb.kind == tyObject) and
(inheritanceDiff(bb, aa) < 0): (inheritanceDiff(bb, aa) < 0):
nil discard
else: else:
return return
result = true result = true

View file

@ -39,7 +39,7 @@ proc addDotDependency(c: PPassContext, n: PNode): PNode =
of nkStmtList, nkBlockStmt, nkStmtListExpr, nkBlockExpr: of nkStmtList, nkBlockStmt, nkStmtListExpr, nkBlockExpr:
for i in countup(0, sonsLen(n) - 1): discard addDotDependency(c, n.sons[i]) for i in countup(0, sonsLen(n) - 1): discard addDotDependency(c, n.sons[i])
else: else:
nil discard
proc generateDot(project: string) = proc generateDot(project: string) =
writeRope(ropef("digraph $1 {$n$2}$n", [ writeRope(ropef("digraph $1 {$n$2}$n", [

View file

@ -27,7 +27,7 @@ proc close(p: PPassContext, n: PNode): PNode =
try: try:
generateIndex(g.doc) generateIndex(g.doc)
except EIO: except EIO:
nil discard
proc processNode(c: PPassContext, n: PNode): PNode = proc processNode(c: PPassContext, n: PNode): PNode =
result = n result = n
@ -46,4 +46,4 @@ proc myOpen(module: PSym): PPassContext =
const docgen2Pass* = makePass(open = myOpen, process = processNode, close = close) const docgen2Pass* = makePass(open = myOpen, process = processNode, close = close)
proc finishDoc2Pass*(project: string) = proc finishDoc2Pass*(project: string) =
nil discard

View file

@ -55,7 +55,7 @@ proc scanPar(p: var TTmplParser, d: int) =
of ']': dec(p.bracket) of ']': dec(p.bracket)
of '{': inc(p.curly) of '{': inc(p.curly)
of '}': dec(p.curly) of '}': dec(p.curly)
else: nil else: discard
inc(i) inc(i)
proc withInExpr(p: TTmplParser): bool {.inline.} = proc withInExpr(p: TTmplParser): bool {.inline.} =

View file

@ -439,7 +439,7 @@ proc impliesLe(fact, x, c: PNode): TImplication =
if leValue(c, fact.sons[1].pred): result = impNo if leValue(c, fact.sons[1].pred): result = impNo
of mNot, mOr, mAnd: internalError(x.info, "impliesLe") of mNot, mOr, mAnd: internalError(x.info, "impliesLe")
else: nil else: discard
proc impliesLt(fact, x, c: PNode): TImplication = proc impliesLt(fact, x, c: PNode): TImplication =
# x < 3 same as x <= 2: # x < 3 same as x <= 2:

View file

@ -81,7 +81,7 @@ proc hlo(c: PContext, n: PNode): PNode =
else: else:
# perform type checking, so that the replacement still fits: # perform type checking, so that the replacement still fits:
if isEmptyType(n.typ) and isEmptyType(result.typ): if isEmptyType(n.typ) and isEmptyType(result.typ):
nil discard
else: else:
result = fitNode(c, n.typ, result) result = fitNode(c, n.typ, result)
# optimization has been applied so check again: # optimization has been applied so check again:

View file

@ -143,7 +143,7 @@ proc mangle(name: string): string =
of 'A'..'Z': of 'A'..'Z':
add(result, chr(ord(name[i]) - ord('A') + ord('a'))) add(result, chr(ord(name[i]) - ord('A') + ord('a')))
of '_': of '_':
nil discard
of 'a'..'z', '0'..'9': of 'a'..'z', '0'..'9':
add(result, name[i]) add(result, name[i])
else: add(result, 'X' & toHex(ord(name[i]), 2)) else: add(result, 'X' & toHex(ord(name[i]), 2))
@ -996,10 +996,10 @@ proc genSym(p: PProc, n: PNode, r: var TCompRes) =
r.res = s.loc.r r.res = s.loc.r
if lfNoDecl in s.loc.flags or s.magic != mNone or if lfNoDecl in s.loc.flags or s.magic != mNone or
{sfImportc, sfInfixCall} * s.flags != {}: {sfImportc, sfInfixCall} * s.flags != {}:
nil discard
elif s.kind == skMethod and s.getBody.kind == nkEmpty: elif s.kind == skMethod and s.getBody.kind == nkEmpty:
# we cannot produce code for the dispatcher yet: # we cannot produce code for the dispatcher yet:
nil discard
elif sfForward in s.flags: elif sfForward in s.flags:
p.g.forwarded.add(s) p.g.forwarded.add(s)
elif not p.g.generatedSyms.containsOrIncl(s.id): elif not p.g.generatedSyms.containsOrIncl(s.id):
@ -1336,10 +1336,10 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) =
else: else:
unaryExpr(p, n, r, "", "($1.length-1)") unaryExpr(p, n, r, "", "($1.length-1)")
of mInc: of mInc:
if not (optOverflowCheck in p.options): binaryExpr(p, n, r, "", "$1 += $2") if optOverflowCheck notin p.options: binaryExpr(p, n, r, "", "$1 += $2")
else: binaryExpr(p, n, r, "addInt", "$1 = addInt($1, $2)") else: binaryExpr(p, n, r, "addInt", "$1 = addInt($1, $2)")
of ast.mDec: of ast.mDec:
if not (optOverflowCheck in p.options): binaryExpr(p, n, r, "", "$1 -= $2") if optOverflowCheck notin p.options: binaryExpr(p, n, r, "", "$1 -= $2")
else: binaryExpr(p, n, r, "subInt", "$1 = subInt($1, $2)") else: binaryExpr(p, n, r, "subInt", "$1 = subInt($1, $2)")
of mSetLengthStr: binaryExpr(p, n, r, "", "$1.length = ($2)-1") of mSetLengthStr: binaryExpr(p, n, r, "", "$1.length = ($2)-1")
of mSetLengthSeq: binaryExpr(p, n, r, "", "$1.length = $2") of mSetLengthSeq: binaryExpr(p, n, r, "", "$1.length = $2")
@ -1544,7 +1544,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
r.res = toRope(n.intVal) r.res = toRope(n.intVal)
of nkNilLit: of nkNilLit:
if isEmptyType(n.typ): if isEmptyType(n.typ):
nil discard
elif mapType(n.typ) == etyBaseIndex: elif mapType(n.typ) == etyBaseIndex:
r.typ = etyBaseIndex r.typ = etyBaseIndex
r.address = toRope"null" | toRope"nil" r.address = toRope"null" | toRope"nil"
@ -1592,12 +1592,12 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
of nkChckRange: genRangeChck(p, n, r, "chckRange") of nkChckRange: genRangeChck(p, n, r, "chckRange")
of nkStringToCString: convStrToCStr(p, n, r) of nkStringToCString: convStrToCStr(p, n, r)
of nkCStringToString: convCStrToStr(p, n, r) of nkCStringToString: convCStrToStr(p, n, r)
of nkEmpty: nil of nkEmpty: discard
of nkLambdaKinds: of nkLambdaKinds:
let s = n.sons[namePos].sym let s = n.sons[namePos].sym
discard mangleName(s) discard mangleName(s)
r.res = s.loc.r r.res = s.loc.r
if lfNoDecl in s.loc.flags or s.magic != mNone: nil if lfNoDecl in s.loc.flags or s.magic != mNone: discard
elif not p.g.generatedSyms.containsOrIncl(s.id): elif not p.g.generatedSyms.containsOrIncl(s.id):
app(p.locals, genProc(p, s)) app(p.locals, genProc(p, s))
of nkMetaNode: gen(p, n.sons[0], r) of nkMetaNode: gen(p, n.sons[0], r)
@ -1614,7 +1614,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
of nkIfStmt, nkIfExpr: genIf(p, n, r) of nkIfStmt, nkIfExpr: genIf(p, n, r)
of nkWhileStmt: genWhileStmt(p, n) of nkWhileStmt: genWhileStmt(p, n)
of nkVarSection, nkLetSection: genVarStmt(p, n) of nkVarSection, nkLetSection: genVarStmt(p, n)
of nkConstSection: nil of nkConstSection: discard
of nkForStmt, nkParForStmt: of nkForStmt, nkParForStmt:
internalError(n.info, "for statement not eliminated") internalError(n.info, "for statement not eliminated")
of nkCaseStmt: of nkCaseStmt:
@ -1633,7 +1633,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
of nkRaiseStmt: genRaiseStmt(p, n) of nkRaiseStmt: genRaiseStmt(p, n)
of nkTypeSection, nkCommentStmt, nkIteratorDef, nkIncludeStmt, of nkTypeSection, nkCommentStmt, nkIteratorDef, nkIncludeStmt,
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt, nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
nkFromStmt, nkTemplateDef, nkMacroDef, nkPragma: nil nkFromStmt, nkTemplateDef, nkMacroDef, nkPragma: discard
of nkProcDef, nkMethodDef, nkConverterDef: of nkProcDef, nkMethodDef, nkConverterDef:
var s = n.sons[namePos].sym var s = n.sons[namePos].sym
if {sfExportc, sfCompilerProc} * s.flags == {sfExportc}: if {sfExportc, sfCompilerProc} * s.flags == {sfExportc}:

View file

@ -1,7 +1,7 @@
# #
# #
# The Nimrod Compiler # The Nimrod Compiler
# (c) Copyright 2013 Andreas Rumpf # (c) Copyright 2014 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -275,7 +275,7 @@ proc captureVar(o: POuterContext, i: PInnerContext, local: PSym,
addCapturedVar(it, local) addCapturedVar(it, local)
if it == e: if it == e:
# common case: local directly in current environment: # common case: local directly in current environment:
nil discard
else: else:
# it's in some upper environment: # it's in some upper environment:
access = indirectAccess(access, addDep(e, it, i.fn), info) access = indirectAccess(access, addDep(e, it, i.fn), info)
@ -314,7 +314,7 @@ proc gatherVars(o: POuterContext, i: PInnerContext, n: PNode) =
if o.currentEnv != env: if o.currentEnv != env:
discard addDep(o.currentEnv, env, i.fn) discard addDep(o.currentEnv, env, i.fn)
internalError(n.info, "too complex environment handling required") internalError(n.info, "too complex environment handling required")
of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: nil of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: discard
else: else:
for k in countup(0, sonsLen(n) - 1): for k in countup(0, sonsLen(n) - 1):
gatherVars(o, i, n.sons[k]) gatherVars(o, i, n.sons[k])
@ -351,7 +351,7 @@ proc makeClosure(prc, env: PSym, info: TLineInfo): PNode =
proc transformInnerProc(o: POuterContext, i: PInnerContext, n: PNode): PNode = proc transformInnerProc(o: POuterContext, i: PInnerContext, n: PNode): PNode =
case n.kind case n.kind
of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: nil of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: discard
of nkSym: of nkSym:
let s = n.sym let s = n.sym
if s == i.fn: if s == i.fn:
@ -371,7 +371,7 @@ proc transformInnerProc(o: POuterContext, i: PInnerContext, n: PNode): PNode =
of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef, of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef,
nkIteratorDef: nkIteratorDef:
# don't recurse here: # don't recurse here:
nil discard
else: else:
for j in countup(0, sonsLen(n) - 1): for j in countup(0, sonsLen(n) - 1):
let x = transformInnerProc(o, i, n.sons[j]) let x = transformInnerProc(o, i, n.sons[j])
@ -386,7 +386,7 @@ proc searchForInnerProcs(o: POuterContext, n: PNode) =
if n == nil: return if n == nil: return
case n.kind case n.kind
of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit:
nil discard
of nkSym: of nkSym:
if isInnerProc(n.sym, o.fn) and not containsOrIncl(o.processed, n.sym.id): if isInnerProc(n.sym, o.fn) and not containsOrIncl(o.processed, n.sym.id):
var inner = newInnerContext(n.sym) var inner = newInnerContext(n.sym)
@ -422,7 +422,7 @@ proc searchForInnerProcs(o: POuterContext, n: PNode) =
# counts, not the block where it is captured! # counts, not the block where it is captured!
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
var it = n.sons[i] var it = n.sons[i]
if it.kind == nkCommentStmt: nil if it.kind == nkCommentStmt: discard
elif it.kind == nkIdentDefs: elif it.kind == nkIdentDefs:
var L = sonsLen(it) var L = sonsLen(it)
if it.sons[0].kind != nkSym: internalError(it.info, "transformOuter") if it.sons[0].kind != nkSym: internalError(it.info, "transformOuter")
@ -441,7 +441,7 @@ proc searchForInnerProcs(o: POuterContext, n: PNode) =
nkIteratorDef: nkIteratorDef:
# don't recurse here: # don't recurse here:
# XXX recurse here and setup 'up' pointers # XXX recurse here and setup 'up' pointers
nil discard
else: else:
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
searchForInnerProcs(o, n.sons[i]) searchForInnerProcs(o, n.sons[i])
@ -500,7 +500,7 @@ proc generateClosureCreation(o: POuterContext, scope: PEnv): PNode =
proc transformOuterProc(o: POuterContext, n: PNode): PNode = proc transformOuterProc(o: POuterContext, n: PNode): PNode =
if n == nil: return nil if n == nil: return nil
case n.kind case n.kind
of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: nil of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: discard
of nkSym: of nkSym:
var local = n.sym var local = n.sym
var closure = PEnv(idTableGet(o.lambdasToEnv, local)) var closure = PEnv(idTableGet(o.lambdasToEnv, local))
@ -540,7 +540,7 @@ proc transformOuterProc(o: POuterContext, n: PNode): PNode =
of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef, of nkProcDef, nkMethodDef, nkConverterDef, nkMacroDef, nkTemplateDef,
nkIteratorDef: nkIteratorDef:
# don't recurse here: # don't recurse here:
nil discard
of nkHiddenStdConv, nkHiddenSubConv, nkConv: of nkHiddenStdConv, nkHiddenSubConv, nkConv:
let x = transformOuterProc(o, n.sons[1]) let x = transformOuterProc(o, n.sons[1])
if x != nil: n.sons[1] = x if x != nil: n.sons[1] = x
@ -625,7 +625,7 @@ proc transfIterBody(c: var TIterContext, n: PNode): PNode =
if interestingIterVar(s) and c.iter.id == s.owner.id: if interestingIterVar(s) and c.iter.id == s.owner.id:
if not containsOrIncl(c.capturedVars, s.id): addField(c.tup, s) if not containsOrIncl(c.capturedVars, s.id): addField(c.tup, s)
result = indirectAccess(newSymNode(c.closureParam), s, n.info) result = indirectAccess(newSymNode(c.closureParam), s, n.info)
of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: nil of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: discard
of nkYieldStmt: of nkYieldStmt:
inc c.state.typ.n.sons[1].intVal inc c.state.typ.n.sons[1].intVal
let stateNo = c.state.typ.n.sons[1].intVal let stateNo = c.state.typ.n.sons[1].intVal

View file

@ -434,7 +434,7 @@ proc handleHexChar(L: var TLexer, xi: var int) =
of 'A'..'F': of 'A'..'F':
xi = (xi shl 4) or (ord(L.buf[L.bufpos]) - ord('A') + 10) xi = (xi shl 4) or (ord(L.buf[L.bufpos]) - ord('A') + 10)
inc(L.bufpos) inc(L.bufpos)
else: nil else: discard
proc handleDecChars(L: var TLexer, xi: var int) = proc handleDecChars(L: var TLexer, xi: var int) =
while L.buf[L.bufpos] in {'0'..'9'}: while L.buf[L.bufpos] in {'0'..'9'}:

View file

@ -286,7 +286,7 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym =
o.symChoiceIndex = 1 o.symChoiceIndex = 1
o.inSymChoice = initIntSet() o.inSymChoice = initIntSet()
incl(o.inSymChoice, result.id) incl(o.inSymChoice, result.id)
else: nil else: discard
if result != nil and result.kind == skStub: loadStub(result) if result != nil and result.kind == skStub: loadStub(result)
proc lastOverloadScope*(o: TOverloadIter): int = proc lastOverloadScope*(o: TOverloadIter): int =

View file

@ -113,7 +113,7 @@ type
warnDifferentHeaps, warnWriteToForeignHeap, warnImplicitClosure, warnDifferentHeaps, warnWriteToForeignHeap, warnImplicitClosure,
warnEachIdentIsTuple, warnShadowIdent, warnEachIdentIsTuple, warnShadowIdent,
warnProveInit, warnProveField, warnProveIndex, warnProveInit, warnProveField, warnProveIndex,
warnUninit, warnUser, warnUninit, warnGcMem, warnUser,
hintSuccess, hintSuccessX, hintSuccess, hintSuccessX,
hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded,
hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled,
@ -370,6 +370,7 @@ const
warnProveField: "cannot prove that field '$1' is accessible [ProveField]", warnProveField: "cannot prove that field '$1' is accessible [ProveField]",
warnProveIndex: "cannot prove index '$1' is valid [ProveIndex]", warnProveIndex: "cannot prove index '$1' is valid [ProveIndex]",
warnUninit: "'$1' might not have been initialized [Uninit]", warnUninit: "'$1' might not have been initialized [Uninit]",
warnGcMem: "'$1' uses GC'ed memory [GcMem]",
warnUser: "$1 [User]", warnUser: "$1 [User]",
hintSuccess: "operation successful [Success]", hintSuccess: "operation successful [Success]",
hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#) [SuccessX]", hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#) [SuccessX]",
@ -389,7 +390,7 @@ const
hintUser: "$1 [User]"] hintUser: "$1 [User]"]
const const
WarningsToStr*: array[0..23, string] = ["CannotOpenFile", "OctalEscape", WarningsToStr*: array[0..24, string] = ["CannotOpenFile", "OctalEscape",
"XIsNeverRead", "XmightNotBeenInit", "XIsNeverRead", "XmightNotBeenInit",
"Deprecated", "ConfigDeprecated", "Deprecated", "ConfigDeprecated",
"SmallLshouldNotBeUsed", "UnknownMagic", "SmallLshouldNotBeUsed", "UnknownMagic",
@ -397,7 +398,7 @@ const
"CommentXIgnored", "NilStmt", "CommentXIgnored", "NilStmt",
"AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap", "AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap",
"ImplicitClosure", "EachIdentIsTuple", "ShadowIdent", "ImplicitClosure", "EachIdentIsTuple", "ShadowIdent",
"ProveInit", "ProveField", "ProveIndex", "Uninit", "User"] "ProveInit", "ProveField", "ProveIndex", "Uninit", "GcMem", "User"]
HintsToStr*: array[0..15, string] = ["Success", "SuccessX", "LineTooLong", HintsToStr*: array[0..15, string] = ["Success", "SuccessX", "LineTooLong",
"XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded",
@ -856,6 +857,5 @@ ropes.errorHandler = proc (err: TRopesError, msg: string, useWarning: bool) =
of rTokenTooLong: of rTokenTooLong:
internalError("ropes: token too long: " & msg) internalError("ropes: token too long: " & msg)
of rCannotOpenFile: of rCannotOpenFile:
rawMessage(if useWarning: warnCannotOpenFile else: errCannotOpenFile, rawMessage(if useWarning: warnCannotOpenFile else: errCannotOpenFile, msg)
msg)

View file

@ -101,7 +101,7 @@ proc jumpToDirective(L: var TLexer, tok: var TToken, dest: TJumpDest) =
break break
if nestedIfs > 0: dec(nestedIfs) if nestedIfs > 0: dec(nestedIfs)
else: else:
nil discard
ppGetTok(L, tok) ppGetTok(L, tok)
elif tok.tokType == tkEof: elif tok.tokType == tkEof:
lexMessage(L, errTokenExpected, "@end") lexMessage(L, errTokenExpected, "@end")

View file

@ -16,3 +16,5 @@ import:testability
@if windows: @if windows:
cincludes: "$lib/wrappers/libffi/common" cincludes: "$lib/wrappers/libffi/common"
@end @end
cs:partial

View file

@ -1817,7 +1817,7 @@ proc parseStmt(p: var TParser): PNode =
withInd(p): withInd(p):
while true: while true:
if p.tok.indent == p.currInd: if p.tok.indent == p.currInd:
nil discard
elif p.tok.tokType == tkSemiColon: elif p.tok.tokType == tkSemiColon:
getTok(p) getTok(p)
if p.tok.indent < 0 or p.tok.indent == p.currInd: discard if p.tok.indent < 0 or p.tok.indent == p.currInd: discard

View file

@ -41,7 +41,7 @@ proc cleanUp(c: PPassContext, n: PNode): PNode =
if sfDeadCodeElim notin getModule(s).flags and not astNeeded(s): if sfDeadCodeElim notin getModule(s).flags and not astNeeded(s):
s.ast.sons[bodyPos] = ast.emptyNode # free the memory s.ast.sons[bodyPos] = ast.emptyNode # free the memory
else: else:
nil discard
const cleanupPass* = makePass(process = cleanUp, close = cleanUp) const cleanupPass* = makePass(process = cleanUp, close = cleanUp)

View file

@ -40,7 +40,7 @@ proc canonKind(n: PNode): TNodeKind =
of nkCallKinds: result = nkCall of nkCallKinds: result = nkCall
of nkStrLit..nkTripleStrLit: result = nkStrLit of nkStrLit..nkTripleStrLit: result = nkStrLit
of nkFastAsgn: result = nkAsgn of nkFastAsgn: result = nkAsgn
else: nil else: discard
proc sameKinds(a, b: PNode): bool {.inline.} = proc sameKinds(a, b: PNode): bool {.inline.} =
result = a.kind == b.kind or a.canonKind == b.canonKind result = a.kind == b.kind or a.canonKind == b.canonKind
@ -267,7 +267,7 @@ proc applyRule*(c: PContext, s: PSym, n: PNode): PNode =
var rs = result.sons[i] var rs = result.sons[i]
let param = params.sons[i].sym let param = params.sons[i].sym
case whichAlias(param) case whichAlias(param)
of aqNone: nil of aqNone: discard
of aqShouldAlias: of aqShouldAlias:
# it suffices that it aliases for sure with *some* other param: # it suffices that it aliases for sure with *some* other param:
var ok = false var ok = false

View file

@ -60,7 +60,7 @@ proc searchForProcOld*(c: PContext, scope: PScope, fn: PSym): PSym =
localError(fn.info, errNotOverloadable, fn.name.s) localError(fn.info, errNotOverloadable, fn.name.s)
return return
of paramsNotEqual: of paramsNotEqual:
nil discard
result = nextIdentIter(it, scope.symbols) result = nextIdentIter(it, scope.symbols)
proc searchForProcNew(c: PContext, scope: PScope, fn: PSym): PSym = proc searchForProcNew(c: PContext, scope: PScope, fn: PSym): PSym =

View file

@ -236,7 +236,7 @@ proc containsNL(s: string): bool =
of '\x0D', '\x0A': of '\x0D', '\x0A':
return true return true
else: else:
nil discard
result = false result = false
proc pushCom(g: var TSrcGen, n: PNode) = proc pushCom(g: var TSrcGen, n: PNode) =
@ -487,7 +487,7 @@ proc hasCom(n: PNode): bool =
result = false result = false
if n.comment != nil: return true if n.comment != nil: return true
case n.kind case n.kind
of nkEmpty..nkNilLit: nil of nkEmpty..nkNilLit: discard
else: else:
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
if hasCom(n.sons[i]): return true if hasCom(n.sons[i]): return true
@ -769,7 +769,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
if n.comment != nil: pushCom(g, n) if n.comment != nil: pushCom(g, n)
case n.kind # atoms: case n.kind # atoms:
of nkTripleStrLit: putRawStr(g, tkTripleStrLit, n.strVal) of nkTripleStrLit: putRawStr(g, tkTripleStrLit, n.strVal)
of nkEmpty: nil of nkEmpty: discard
of nkType: put(g, tkInvalid, atom(n)) of nkType: put(g, tkInvalid, atom(n))
of nkSym, nkIdent: gident(g, n) of nkSym, nkIdent: gident(g, n)
of nkIntLit: put(g, tkIntLit, atom(n)) of nkIntLit: put(g, tkIntLit, atom(n))
@ -1273,7 +1273,7 @@ proc renderModule(n: PNode, filename: string,
case n.sons[i].kind case n.sons[i].kind
of nkTypeSection, nkConstSection, nkVarSection, nkLetSection, of nkTypeSection, nkConstSection, nkVarSection, nkLetSection,
nkCommentStmt: putNL(g) nkCommentStmt: putNL(g)
else: nil else: discard
gcoms(g) gcoms(g)
if optStdout in gGlobalOptions: if optStdout in gGlobalOptions:
write(stdout, g.buf) write(stdout, g.buf)

View file

@ -539,7 +539,7 @@ proc cmdChangeTriggersRecompilation(old, new: TCommands): bool =
of cmdNone, cmdDoc, cmdInterpret, cmdPretty, cmdGenDepend, cmdDump, of cmdNone, cmdDoc, cmdInterpret, cmdPretty, cmdGenDepend, cmdDump,
cmdCheck, cmdParse, cmdScan, cmdIdeTools, cmdDef, cmdCheck, cmdParse, cmdScan, cmdIdeTools, cmdDef,
cmdRst2html, cmdRst2tex, cmdInteractive, cmdRun: cmdRst2html, cmdRst2tex, cmdInteractive, cmdRun:
nil discard
# else: trigger recompilation: # else: trigger recompilation:
result = true result = true

View file

@ -573,7 +573,7 @@ proc process(c: PPassContext, n: PNode): PNode =
of nkPragma: of nkPragma:
addStmt(w, n) addStmt(w, n)
else: else:
nil discard
proc myOpen(module: PSym): PPassContext = proc myOpen(module: PSym): PPassContext =
if module.id < 0: internalError("rodwrite: module ID not set") if module.id < 0: internalError("rodwrite: module ID not set")

View file

@ -71,7 +71,7 @@ proc pickBestCandidate(c: PContext, headSymbol: PNode,
var cmp = cmpCandidates(best, z) var cmp = cmpCandidates(best, z)
if cmp < 0: best = z # x is better than the best so far if cmp < 0: best = z # x is better than the best so far
elif cmp == 0: alt = z # x is as good as the best so far elif cmp == 0: alt = z # x is as good as the best so far
else: nil else: discard
sym = nextOverloadIter(o, c, headSymbol) sym = nextOverloadIter(o, c, headSymbol)
proc notFoundError*(c: PContext, n: PNode, errors: seq[string]) = proc notFoundError*(c: PContext, n: PNode, errors: seq[string]) =

View file

@ -168,7 +168,7 @@ proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus =
if not compareTypes(castDest, src, dcEqIgnoreDistinct): if not compareTypes(castDest, src, dcEqIgnoreDistinct):
result = convNotLegal result = convNotLegal
else: else:
nil discard
proc isCastable(dst, src: PType): bool = proc isCastable(dst, src: PType): bool =
#const #const
@ -204,7 +204,7 @@ proc semConv(c: PContext, n: PNode): PNode =
if not isSymChoice(op): if not isSymChoice(op):
let status = checkConvertible(c, result.typ, op.typ) let status = checkConvertible(c, result.typ, op.typ)
case status case status
of convOK: nil of convOK: discard
of convNotNeedeed: of convNotNeedeed:
message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString) message(n.info, hintConvFromXtoItselfNotNeeded, result.typ.typeToString)
of convNotLegal: of convNotLegal:
@ -397,7 +397,7 @@ proc changeType(n: PNode, newType: PType, check: bool) =
of nkPar: of nkPar:
if newType.kind != tyTuple: if newType.kind != tyTuple:
internalError(n.info, "changeType: no tuple type for constructor") internalError(n.info, "changeType: no tuple type for constructor")
elif newType.n == nil: nil elif newType.n == nil: discard
elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr: elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr:
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
var m = n.sons[i].sons[0] var m = n.sons[i].sons[0]
@ -423,7 +423,7 @@ proc changeType(n: PNode, newType: PType, check: bool) =
if value < firstOrd(newType) or value > lastOrd(newType): if value < firstOrd(newType) or value > lastOrd(newType):
localError(n.info, errGenerated, "cannot convert " & $value & localError(n.info, errGenerated, "cannot convert " & $value &
" to " & typeToString(newType)) " to " & typeToString(newType))
else: nil else: discard
n.typ = newType n.typ = newType
proc arrayConstrType(c: PContext, n: PNode): PType = proc arrayConstrType(c: PContext, n: PNode): PType =
@ -513,7 +513,7 @@ proc fixAbstractType(c: PContext, n: PNode) =
# an implicitly constructed array (passed to an open array): # an implicitly constructed array (passed to an open array):
n.sons[i] = semArrayConstr(c, it, {}) n.sons[i] = semArrayConstr(c, it, {})
else: else:
nil discard
#if (it.typ == nil): #if (it.typ == nil):
# InternalError(it.info, "fixAbstractType: " & renderTree(it)) # InternalError(it.info, "fixAbstractType: " & renderTree(it))
@ -677,7 +677,7 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
return return
let callee = result.sons[0].sym let callee = result.sons[0].sym
case callee.kind case callee.kind
of skMacro, skTemplate: nil of skMacro, skTemplate: discard
else: else:
if (callee.kind == skIterator) and (callee.id == c.p.owner.id): if (callee.kind == skIterator) and (callee.id == c.p.owner.id):
localError(n.info, errRecursiveDependencyX, callee.name.s) localError(n.info, errRecursiveDependencyX, callee.name.s)
@ -1098,7 +1098,7 @@ proc takeImplicitAddr(c: PContext, n: PNode): PNode =
of nkHiddenDeref, nkDerefExpr: return n.sons[0] of nkHiddenDeref, nkDerefExpr: return n.sons[0]
of nkBracketExpr: of nkBracketExpr:
if len(n) == 1: return n.sons[0] if len(n) == 1: return n.sons[0]
else: nil else: discard
var valid = isAssignable(c, n) var valid = isAssignable(c, n)
if valid != arLValue: if valid != arLValue:
if valid == arLocalLValue: if valid == arLocalLValue:
@ -1207,7 +1207,7 @@ proc semProcBody(c: PContext, n: PNode): PNode =
# transform ``expr`` to ``result = expr``, but not if the expr is already # transform ``expr`` to ``result = expr``, but not if the expr is already
# ``result``: # ``result``:
if result.kind == nkSym and result.sym == c.p.resultSym: if result.kind == nkSym and result.sym == c.p.resultSym:
nil discard
elif result.kind == nkNilLit: elif result.kind == nkNilLit:
# or ImplicitlyDiscardable(result): # or ImplicitlyDiscardable(result):
# new semantic: 'result = x' triggers the void context # new semantic: 'result = x' triggers the void context
@ -1244,7 +1244,7 @@ proc semYieldVarResult(c: PContext, n: PNode, restype: PType) =
a.sons[i] = takeImplicitAddr(c, a.sons[i]) a.sons[i] = takeImplicitAddr(c, a.sons[i])
else: else:
localError(n.sons[0].info, errXExpected, "tuple constructor") localError(n.sons[0].info, errXExpected, "tuple constructor")
else: nil else: discard
proc semYield(c: PContext, n: PNode): PNode = proc semYield(c: PContext, n: PNode): PNode =
result = n result = n
@ -1472,7 +1472,7 @@ proc tryExpr(c: PContext, n: PNode,
result = semExpr(c, n, flags) result = semExpr(c, n, flags)
if msgs.gErrorCounter != oldErrorCount: result = nil if msgs.gErrorCounter != oldErrorCount: result = nil
except ERecoverableError: except ERecoverableError:
nil discard
# undo symbol table changes (as far as it's possible): # undo symbol table changes (as far as it's possible):
c.generics = oldGenerics c.generics = oldGenerics
c.inGenericContext = oldInGenericContext c.inGenericContext = oldInGenericContext
@ -1590,9 +1590,9 @@ proc semSetConstr(c: PContext, n: PNode): PNode =
typ = skipTypes(n.sons[i].typ, {tyGenericInst, tyVar, tyOrdinal}) typ = skipTypes(n.sons[i].typ, {tyGenericInst, tyVar, tyOrdinal})
if not isOrdinalType(typ): if not isOrdinalType(typ):
localError(n.info, errOrdinalTypeExpected) localError(n.info, errOrdinalTypeExpected)
typ = makeRangeType(c, 0, MaxSetElements - 1, n.info) typ = makeRangeType(c, 0, MaxSetElements-1, n.info)
elif lengthOrd(typ) > MaxSetElements: elif lengthOrd(typ) > MaxSetElements:
typ = makeRangeType(c, 0, MaxSetElements - 1, n.info) typ = makeRangeType(c, 0, MaxSetElements-1, n.info)
addSonSkipIntLit(result.typ, typ) addSonSkipIntLit(result.typ, typ)
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
var m: PNode var m: PNode
@ -1659,8 +1659,7 @@ proc semTupleFieldsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
typ.n = newNodeI(nkRecList, n.info) # nkIdentDefs typ.n = newNodeI(nkRecList, n.info) # nkIdentDefs
var ids = initIntSet() var ids = initIntSet()
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
if (n.sons[i].kind != nkExprColonExpr) or if n[i].kind != nkExprColonExpr or n[i][0].kind notin {nkSym, nkIdent}:
not (n.sons[i].sons[0].kind in {nkSym, nkIdent}):
illFormedAst(n.sons[i]) illFormedAst(n.sons[i])
var id: PIdent var id: PIdent
if n.sons[i].sons[0].kind == nkIdent: id = n.sons[i].sons[0].ident if n.sons[i].sons[0].kind == nkIdent: id = n.sons[i].sons[0].ident

View file

@ -222,7 +222,7 @@ proc getIntervalType*(m: TMagic, n: PNode): PType =
commutativeOp(min) commutativeOp(min)
of mMaxI, mMaxI64: of mMaxI, mMaxI64:
commutativeOp(max) commutativeOp(max)
else: nil else: discard
discard """ discard """
mShlI, mShlI64, mShlI, mShlI64,
@ -546,7 +546,7 @@ proc foldArrayAccess(m: PSym, n: PNode): PNode =
if (idx >= 0) and (idx < len(x.strVal)): if (idx >= 0) and (idx < len(x.strVal)):
result.intVal = ord(x.strVal[int(idx)]) result.intVal = ord(x.strVal[int(idx)])
elif idx == len(x.strVal): elif idx == len(x.strVal):
nil discard
else: else:
localError(n.info, errIndexOutOfBounds) localError(n.info, errIndexOutOfBounds)
else: discard else: discard

View file

@ -53,7 +53,7 @@ proc semTypeTraits(c: PContext, n: PNode): PNode =
if t.sonsLen > 0: if t.sonsLen > 0:
# This is either a type known to sem or a typedesc # This is either a type known to sem or a typedesc
# param to a regular proc (again, known at instantiation) # param to a regular proc (again, known at instantiation)
result = evalTypeTrait(n[0], t, GetCurrOwner()) result = evalTypeTrait(n[0], t, getCurrOwner())
else: else:
# a typedesc variable, pass unmodified to evals # a typedesc variable, pass unmodified to evals
result = n result = n

View file

@ -136,6 +136,7 @@ proc discardCheck(c: PContext, result: PNode) =
if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}: if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}:
if result.kind == nkNilLit: if result.kind == nkNilLit:
result.typ = nil result.typ = nil
message(result.info, warnNilStatement)
elif implicitlyDiscardable(result): elif implicitlyDiscardable(result):
var n = result var n = result
result.typ = nil result.typ = nil
@ -145,10 +146,11 @@ proc discardCheck(c: PContext, result: PNode) =
elif c.inTypeClass > 0 and result.typ.kind == tyBool: elif c.inTypeClass > 0 and result.typ.kind == tyBool:
let verdict = semConstExpr(c, result) let verdict = semConstExpr(c, result)
if verdict.intVal == 0: if verdict.intVal == 0:
localError(result.info, "type class predicate failed.") localError(result.info, "type class predicate failed")
elif result.typ.kind != tyError and gCmd != cmdInteractive: elif result.typ.kind != tyError and gCmd != cmdInteractive:
if result.typ.kind == tyNil: if result.typ.kind == tyNil:
fixNilType(result) fixNilType(result)
message(result.info, warnNilStatement)
else: else:
var n = result var n = result
while n.kind in skipForDiscardable: n = n.lastSon while n.kind in skipForDiscardable: n = n.lastSon
@ -996,7 +998,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
if proto == nil: if proto == nil:
s.typ.callConv = lastOptionEntry(c).defaultCC s.typ.callConv = lastOptionEntry(c).defaultCC
# add it here, so that recursive procs are possible: # add it here, so that recursive procs are possible:
if sfGenSym in s.flags: nil if sfGenSym in s.flags: discard
elif kind in OverloadableSyms: elif kind in OverloadableSyms:
if not typeIsDetermined: if not typeIsDetermined:
addInterfaceOverloadableSymAt(c, s.scope, s) addInterfaceOverloadableSymAt(c, s.scope, s)
@ -1252,9 +1254,9 @@ proc semStmtList(c: PContext, n: PNode): PNode =
of LastBlockStmts: of LastBlockStmts:
for j in countup(i + 1, length - 1): for j in countup(i + 1, length - 1):
case n.sons[j].kind case n.sons[j].kind
of nkPragma, nkCommentStmt, nkNilLit, nkEmpty: nil of nkPragma, nkCommentStmt, nkNilLit, nkEmpty: discard
else: localError(n.sons[j].info, errStmtInvalidAfterReturn) else: localError(n.sons[j].info, errStmtInvalidAfterReturn)
else: nil else: discard
if result.len == 1: if result.len == 1:
result = result.sons[0] result = result.sons[0]
when false: when false:

View file

@ -537,7 +537,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int,
if a.kind == nkEmpty: addSon(father, newSymNode(f)) if a.kind == nkEmpty: addSon(father, newSymNode(f))
else: addSon(a, newSymNode(f)) else: addSon(a, newSymNode(f))
if a.kind != nkEmpty: addSon(father, a) if a.kind != nkEmpty: addSon(father, a)
of nkEmpty: nil of nkEmpty: discard
else: illFormedAst(n) else: illFormedAst(n)
proc addInheritedFieldsAux(c: PContext, check: var TIntSet, pos: var int, proc addInheritedFieldsAux(c: PContext, check: var TIntSet, pos: var int,
@ -615,7 +615,7 @@ proc addParamOrResult(c: PContext, param: PSym, kind: TSymKind) =
let typedescId = getIdent"typedesc" let typedescId = getIdent"typedesc"
template shouldHaveMeta(t) = template shouldHaveMeta(t) =
InternalAssert tfHasMeta in t.flags internalAssert tfHasMeta in t.flags
# result.lastSon.flags.incl tfHasMeta # result.lastSon.flags.incl tfHasMeta
proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode, proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
@ -745,7 +745,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
else: else:
result = addImplicitGeneric(newTypeS(tyAnything, c)) result = addImplicitGeneric(newTypeS(tyAnything, c))
else: nil else: discard
# result = liftingWalk(paramType) # result = liftingWalk(paramType)
@ -939,7 +939,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
result = nil result = nil
if gCmd == cmdIdeTools: suggestExpr(c, n) if gCmd == cmdIdeTools: suggestExpr(c, n)
case n.kind case n.kind
of nkEmpty: nil of nkEmpty: discard
of nkTypeOfExpr: of nkTypeOfExpr:
# for ``type(countup(1,3))``, see ``tests/ttoseq``. # for ``type(countup(1,3))``, see ``tests/ttoseq``.
checkSonsLen(n, 1) checkSonsLen(n, 1)
@ -977,7 +977,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
result = freshType(result, prev) result = freshType(result, prev)
result.flags.incl(tfNotNil) result.flags.incl(tfNotNil)
else: else:
LocalError(n.info, errGenerated, "invalid type") localError(n.info, errGenerated, "invalid type")
of 2: of 2:
let negated = semTypeNode(c, n.sons[1], prev) let negated = semTypeNode(c, n.sons[1], prev)
result = makeNotType(c, negated) result = makeNotType(c, negated)
@ -1137,7 +1137,7 @@ proc processMagicType(c: PContext, m: PSym) =
of mSet: setMagicType(m, tySet, 0) of mSet: setMagicType(m, tySet, 0)
of mSeq: setMagicType(m, tySequence, 0) of mSeq: setMagicType(m, tySequence, 0)
of mOrdinal: setMagicType(m, tyOrdinal, 0) of mOrdinal: setMagicType(m, tyOrdinal, 0)
of mPNimrodNode: nil of mPNimrodNode: discard
else: localError(m.info, errTypeExpected) else: localError(m.info, errTypeExpected)
proc semGenericConstraints(c: PContext, x: PType): PType = proc semGenericConstraints(c: PContext, x: PType): PType =

View file

@ -22,7 +22,7 @@ proc checkPartialConstructedType(info: TLineInfo, t: PType) =
proc checkConstructedType*(info: TLineInfo, typ: PType) = proc checkConstructedType*(info: TLineInfo, typ: PType) =
var t = typ.skipTypes({tyDistinct}) var t = typ.skipTypes({tyDistinct})
if t.kind in tyTypeClasses: nil if t.kind in tyTypeClasses: discard
elif tfAcyclic in t.flags and skipTypes(t, abstractInst).kind != tyObject: elif tfAcyclic in t.flags and skipTypes(t, abstractInst).kind != tyObject:
localError(info, errInvalidPragmaX, "acyclic") localError(info, errInvalidPragmaX, "acyclic")
elif t.kind == tyVar and t.sons[0].kind == tyVar: elif t.kind == tyVar and t.sons[0].kind == tyVar:
@ -364,7 +364,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
of tyGenericInst: of tyGenericInst:
result = instCopyType(cl, t) result = instCopyType(cl, t)
for i in 1 .. <result.sonsLen: for i in 1 .. <result.sonsLen:
result.sons[i] = ReplaceTypeVarsT(cl, result.sons[i]) result.sons[i] = replaceTypeVarsT(cl, result.sons[i])
propagateToOwner(result, result.lastSon) propagateToOwner(result, result.lastSon)
else: else:

View file

@ -381,7 +381,7 @@ proc procTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
when useEffectSystem: when useEffectSystem:
if not compatibleEffects(f, a): return isNone if not compatibleEffects(f, a): return isNone
of tyNil: result = f.allowsNil of tyNil: result = f.allowsNil
else: nil else: discard
proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} = proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} =
let let
@ -477,7 +477,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
of tyAnything: of tyAnything:
return if f.kind == tyAnything: isGeneric return if f.kind == tyAnything: isGeneric
else: isNone else: isNone
else: nil else: discard
case f.kind case f.kind
of tyEnum: of tyEnum:
@ -530,7 +530,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
result = typeRel(c, f.sons[1], a.sons[1]) result = typeRel(c, f.sons[1], a.sons[1])
if result < isGeneric: result = isNone if result < isGeneric: result = isNone
elif lengthOrd(fRange) != lengthOrd(a): result = isNone elif lengthOrd(fRange) != lengthOrd(a): result = isNone
else: nil else: discard
of tyOpenArray, tyVarargs: of tyOpenArray, tyVarargs:
case a.kind case a.kind
of tyOpenArray, tyVarargs: of tyOpenArray, tyVarargs:
@ -551,7 +551,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
result = isConvertible result = isConvertible
elif typeRel(c, base(f), a.sons[0]) >= isGeneric: elif typeRel(c, base(f), a.sons[0]) >= isGeneric:
result = isConvertible result = isConvertible
else: nil else: discard
of tySequence: of tySequence:
case a.kind case a.kind
of tySequence: of tySequence:
@ -563,7 +563,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
elif tfNotNil in f.flags and tfNotNil notin a.flags: elif tfNotNil in f.flags and tfNotNil notin a.flags:
result = isNilConversion result = isNilConversion
of tyNil: result = f.allowsNil of tyNil: result = f.allowsNil
else: nil else: discard
of tyOrdinal: of tyOrdinal:
if isOrdinalType(a): if isOrdinalType(a):
var x = if a.kind == tyOrdinal: a.sons[0] else: a var x = if a.kind == tyOrdinal: a.sons[0] else: a
@ -607,7 +607,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
elif tfNotNil in f.flags and tfNotNil notin a.flags: elif tfNotNil in f.flags and tfNotNil notin a.flags:
result = isNilConversion result = isNilConversion
of tyNil: result = f.allowsNil of tyNil: result = f.allowsNil
else: nil else: discard
of tyRef: of tyRef:
case a.kind case a.kind
of tyRef: of tyRef:
@ -616,7 +616,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
elif tfNotNil in f.flags and tfNotNil notin a.flags: elif tfNotNil in f.flags and tfNotNil notin a.flags:
result = isNilConversion result = isNilConversion
of tyNil: result = f.allowsNil of tyNil: result = f.allowsNil
else: nil else: discard
of tyProc: of tyProc:
result = procTypeRel(c, f, a) result = procTypeRel(c, f, a)
if result != isNone and tfNotNil in f.flags and tfNotNil notin a.flags: if result != isNone and tfNotNil in f.flags and tfNotNil notin a.flags:
@ -632,7 +632,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
of tyProc: of tyProc:
if a.callConv != ccClosure: result = isConvertible if a.callConv != ccClosure: result = isConvertible
of tyPtr, tyCString: result = isConvertible of tyPtr, tyCString: result = isConvertible
else: nil else: discard
of tyString: of tyString:
case a.kind case a.kind
of tyString: of tyString:
@ -641,7 +641,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
else: else:
result = isEqual result = isEqual
of tyNil: result = f.allowsNil of tyNil: result = f.allowsNil
else: nil else: discard
of tyCString: of tyCString:
# conversion from string to cstring is automatic: # conversion from string to cstring is automatic:
case a.kind case a.kind
@ -659,7 +659,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
(skipTypes(a.sons[0], {tyRange}).kind in {tyInt..tyInt64}) and (skipTypes(a.sons[0], {tyRange}).kind in {tyInt..tyInt64}) and
(a.sons[1].kind == tyChar): (a.sons[1].kind == tyChar):
result = isConvertible result = isConvertible
else: nil else: discard
of tyEmpty: of tyEmpty:
if a.kind == tyEmpty: result = isEqual if a.kind == tyEmpty: result = isEqual
@ -691,7 +691,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
if x.kind == tyGenericInvokation or f.sons[0].kind != tyGenericBody: if x.kind == tyGenericInvokation or f.sons[0].kind != tyGenericBody:
#InternalError("typeRel: tyGenericInvokation -> tyGenericInvokation") #InternalError("typeRel: tyGenericInvokation -> tyGenericInvokation")
# simply no match for now: # simply no match for now:
nil discard
elif x.kind == tyGenericInst and elif x.kind == tyGenericInst and
(f.sons[0] == x.sons[0]) and (f.sons[0] == x.sons[0]) and
(sonsLen(x) - 1 == sonsLen(f)): (sonsLen(x) - 1 == sonsLen(f)):
@ -947,10 +947,10 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
if e == nil: return nil if e == nil: return nil
case e.kind case e.kind
of nkReturnStmt: nil of nkReturnStmt: discard
of nkTypeSection: nil of nkTypeSection: discard
of nkConstDef: nil of nkConstDef: discard
else: nil else: discard
result = arg result = arg
put(m.bindings, f, a) put(m.bindings, f, a)
@ -976,7 +976,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType,
var var
r: TTypeRelation r: TTypeRelation
a = if c.InTypeClass > 0: argType.skipTypes({tyTypeDesc}) a = if c.inTypeClass > 0: argType.skipTypes({tyTypeDesc})
else: argType else: argType
case fMaybeStatic.kind case fMaybeStatic.kind

View file

@ -103,7 +103,7 @@ proc suggestObject(c: PContext, n: PNode, outputs: var int) =
suggestObject(c, n.sons[0], outputs) suggestObject(c, n.sons[0], outputs)
for i in countup(1, L-1): suggestObject(c, lastSon(n.sons[i]), outputs) for i in countup(1, L-1): suggestObject(c, lastSon(n.sons[i]), outputs)
of nkSym: suggestField(c, n.sym, outputs) of nkSym: suggestField(c, n.sym, outputs)
else: nil else: discard
proc nameFits(c: PContext, s: PSym, n: PNode): bool = proc nameFits(c: PContext, s: PSym, n: PNode): bool =
var op = n.sons[0] var op = n.sons[0]

View file

@ -193,7 +193,7 @@ proc transformConstSection(c: PTransf, v: PNode): PTransNode =
proc hasContinue(n: PNode): bool = proc hasContinue(n: PNode): bool =
case n.kind case n.kind
of nkEmpty..nkNilLit, nkForStmt, nkParForStmt, nkWhileStmt: nil of nkEmpty..nkNilLit, nkForStmt, nkParForStmt, nkWhileStmt: discard
of nkContinueStmt: result = true of nkContinueStmt: result = true
else: else:
for i in countup(0, sonsLen(n) - 1): for i in countup(0, sonsLen(n) - 1):
@ -536,7 +536,7 @@ proc getMergeOp(n: PNode): PSym =
if (n.sons[0].kind == nkSym) and (n.sons[0].sym.kind == skProc) and if (n.sons[0].kind == nkSym) and (n.sons[0].sym.kind == skProc) and
(sfMerge in n.sons[0].sym.flags): (sfMerge in n.sons[0].sym.flags):
result = n.sons[0].sym result = n.sons[0].sym
else: nil else: discard
proc flattenTreeAux(d, a: PNode, op: PSym) = proc flattenTreeAux(d, a: PNode, op: PSym) =
var op2 = getMergeOp(a) var op2 = getMergeOp(a)

View file

@ -345,7 +345,7 @@ proc canFormAcycleAux(marker: var TIntSet, typ: PType, startId: int): bool =
# # damn inheritance may introduce cycles: # # damn inheritance may introduce cycles:
# result = true # result = true
of tyProc: result = typ.callConv == ccClosure of tyProc: result = typ.callConv == ccClosure
else: nil else: discard
proc canFormAcycle(typ: PType): bool = proc canFormAcycle(typ: PType): bool =
var marker = initIntSet() var marker = initIntSet()
@ -432,10 +432,10 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
if t.len == 0: result = "typedesc" if t.len == 0: result = "typedesc"
else: result = "typedesc[" & typeToString(t.sons[0]) & "]" else: result = "typedesc[" & typeToString(t.sons[0]) & "]"
of tyStatic: of tyStatic:
InternalAssert t.len > 0 internalAssert t.len > 0
result = "static[" & typeToString(t.sons[0]) & "]" result = "static[" & typeToString(t.sons[0]) & "]"
of tyTypeClass: of tyTypeClass:
InternalAssert t.sym != nil and t.sym.owner != nil internalAssert t.sym != nil and t.sym.owner != nil
return t.sym.owner.name.s return t.sym.owner.name.s
of tyBuiltInTypeClass: of tyBuiltInTypeClass:
return "TypeClass" return "TypeClass"
@ -446,7 +446,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
of tyNot: of tyNot:
result = "not " & typeToString(t.sons[0]) result = "not " & typeToString(t.sons[0])
of tyExpr: of tyExpr:
InternalAssert t.len == 0 internalAssert t.len == 0
result = "expr" result = "expr"
of tyFromExpr: of tyFromExpr:
result = renderTree(t.n) result = renderTree(t.n)

View file

@ -1333,7 +1333,7 @@ Examples:
# has default calling convention # has default calling convention
echo "x: ", mouseX, " y: ", mouseY echo "x: ", mouseX, " y: ", mouseY
proc setOnMouseMove(mouseMoveEvent: TOnMouseMove) = nil proc setOnMouseMove(mouseMoveEvent: TOnMouseMove) = discard
# ok, 'onMouseMove' has the default calling convention, which is compatible # ok, 'onMouseMove' has the default calling convention, which is compatible
# to 'closure': # to 'closure':

View file

@ -324,12 +324,12 @@ the compiler that for every other value nothing should be done:
case n case n
of 0..2, 4..7: echo("The number is in the set: {0, 1, 2, 4, 5, 6, 7}") of 0..2, 4..7: echo("The number is in the set: {0, 1, 2, 4, 5, 6, 7}")
of 3, 8: echo("The number is 3 or 8") of 3, 8: echo("The number is 3 or 8")
else: nil else: discard
The ``nil`` statement is a *do nothing* statement. The compiler knows that a The empty ``discard`` statement is a *do nothing* statement. The compiler knows
case statement with an else part cannot fail and thus the error disappears. Note that a case statement with an else part cannot fail and thus the error
that it is impossible to cover all possible string values: that is why there is disappears. Note that it is impossible to cover all possible string values:
no such check for string cases. that is why there is no such check for string cases.
In general the case statement is used for subrange types or enumerations where In general the case statement is used for subrange types or enumerations where
it is of great help that the compiler checks that you covered any possible it is of great help that the compiler checks that you covered any possible

View file

@ -614,7 +614,7 @@ simple proc for logging:
.. code-block:: nimrod .. code-block:: nimrod
const const
debug = True debug = true
proc log(msg: string) {.inline.} = proc log(msg: string) {.inline.} =
if debug: stdout.writeln(msg) if debug: stdout.writeln(msg)
@ -631,7 +631,7 @@ Turning the ``log`` proc into a template solves this problem:
.. code-block:: nimrod .. code-block:: nimrod
const const
debug = True debug = true
template log(msg: string) = template log(msg: string) =
if debug: stdout.writeln(msg) if debug: stdout.writeln(msg)
@ -674,16 +674,15 @@ via a special ``:`` syntax:
template withFile(f: expr, filename: string, mode: TFileMode, template withFile(f: expr, filename: string, mode: TFileMode,
body: stmt): stmt {.immediate.} = body: stmt): stmt {.immediate.} =
block: let fn = filename
let fn = filename var f: TFile
var f: TFile if open(f, fn, mode):
if open(f, fn, mode): try:
try: body
body finally:
finally: close(f)
close(f) else:
else: quit("cannot open: " & fn)
quit("cannot open: " & fn)
withFile(txt, "ttempl3.txt", fmWrite): withFile(txt, "ttempl3.txt", fmWrite):
txt.writeln("line 1") txt.writeln("line 1")
@ -784,7 +783,7 @@ regular expressions:
macro case_token(n: stmt): stmt = macro case_token(n: stmt): stmt =
# creates a lexical analyzer from regular expressions # creates a lexical analyzer from regular expressions
# ... (implementation is an exercise for the reader :-) # ... (implementation is an exercise for the reader :-)
nil discard
case_token: # this colon tells the parser it is a macro statement case_token: # this colon tells the parser it is a macro statement
of r"[A-Za-z_]+[A-Za-z_0-9]*": of r"[A-Za-z_]+[A-Za-z_0-9]*":

View file

@ -73,7 +73,7 @@ proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: string) =
g.pos = pos g.pos = pos
proc deinitGeneralTokenizer*(g: var TGeneralTokenizer) = proc deinitGeneralTokenizer*(g: var TGeneralTokenizer) =
nil discard
proc nimGetKeyword(id: string): TTokenClass = proc nimGetKeyword(id: string): TTokenClass =
for k in nimrodKeywords: for k in nimrodKeywords:
@ -102,7 +102,7 @@ proc nimNumberPostfix(g: var TGeneralTokenizer, position: int): int =
if g.buf[pos] in {'0'..'9'}: inc(pos) if g.buf[pos] in {'0'..'9'}: inc(pos)
if g.buf[pos] in {'0'..'9'}: inc(pos) if g.buf[pos] in {'0'..'9'}: inc(pos)
else: else:
nil discard
result = pos result = pos
proc nimNumber(g: var TGeneralTokenizer, position: int): int = proc nimNumber(g: var TGeneralTokenizer, position: int): int =

View file

@ -535,7 +535,7 @@ proc match(p: TRstParser, start: int, expr: string): bool =
case p.tok[j].symbol[0] case p.tok[j].symbol[0]
of 'a'..'z', 'A'..'Z': result = len(p.tok[j].symbol) == 1 of 'a'..'z', 'A'..'Z': result = len(p.tok[j].symbol) == 1
of '0'..'9': result = allCharsInSet(p.tok[j].symbol, {'0'..'9'}) of '0'..'9': result = allCharsInSet(p.tok[j].symbol, {'0'..'9'})
else: nil else: discard
else: else:
var c = expr[i] var c = expr[i]
var length = 0 var length = 0
@ -640,7 +640,7 @@ proc parseUrl(p: var TRstParser, father: PRstNode) =
var n = newRstNode(rnStandaloneHyperlink) var n = newRstNode(rnStandaloneHyperlink)
while true: while true:
case p.tok[p.idx].kind case p.tok[p.idx].kind
of tkWord, tkAdornment, tkOther: nil of tkWord, tkAdornment, tkOther: discard
of tkPunct: of tkPunct:
if p.tok[p.idx+1].kind notin {tkWord, tkAdornment, tkOther, tkPunct}: if p.tok[p.idx+1].kind notin {tkWord, tkAdornment, tkOther, tkPunct}:
break break
@ -806,7 +806,7 @@ proc parseInline(p: var TRstParser, father: PRstNode) =
return return
add(father, newLeaf(p)) add(father, newLeaf(p))
inc(p.idx) inc(p.idx)
else: nil else: discard
proc getDirective(p: var TRstParser): string = proc getDirective(p: var TRstParser): string =
if p.tok[p.idx].kind == tkWhite and p.tok[p.idx+1].kind == tkWord: if p.tok[p.idx].kind == tkWhite and p.tok[p.idx+1].kind == tkWord:
@ -1339,7 +1339,7 @@ proc parseSection(p: var TRstParser, result: PRstNode) =
of rnDirective: a = parseDotDot(p) of rnDirective: a = parseDotDot(p)
of rnEnumList: a = parseEnumList(p) of rnEnumList: a = parseEnumList(p)
of rnLeaf: rstMessage(p, meNewSectionExpected) of rnLeaf: rstMessage(p, meNewSectionExpected)
of rnParagraph: nil of rnParagraph: discard
of rnDefList: a = parseDefinitionList(p) of rnDefList: a = parseDefinitionList(p)
of rnFieldList: of rnFieldList:
if p.idx > 0: dec(p.idx) if p.idx > 0: dec(p.idx)
@ -1351,7 +1351,7 @@ proc parseSection(p: var TRstParser, result: PRstNode) =
of rnOptionList: a = parseOptionList(p) of rnOptionList: a = parseOptionList(p)
else: else:
#InternalError("rst.parseSection()") #InternalError("rst.parseSection()")
nil discard
if a == nil and k != rnDirective: if a == nil and k != rnDirective:
a = newRstNode(rnParagraph) a = newRstNode(rnParagraph)
parseParagraph(p, a) parseParagraph(p, a)
@ -1624,7 +1624,7 @@ proc resolveSubs(p: var TRstParser, n: PRstNode): PRstNode =
add(result, n) add(result, n)
add(result, y) add(result, y)
of rnLeaf: of rnLeaf:
nil discard
of rnContents: of rnContents:
p.hasToc = true p.hasToc = true
else: else:

View file

@ -165,7 +165,7 @@ proc nextSplitPoint*(s: string, start: int): int =
of 'a'..'z': of 'a'..'z':
if result + 1 < len(s) + 0: if result + 1 < len(s) + 0:
if s[result + 1] in {'A'..'Z'}: return if s[result + 1] in {'A'..'Z'}: return
else: nil else: discard
inc(result) inc(result)
dec(result) # last valid index dec(result) # last valid index

View file

@ -626,7 +626,7 @@ proc len*(n: PJsonNode): int =
case n.kind case n.kind
of JArray: result = n.elems.len of JArray: result = n.elems.len
of JObject: result = n.fields.len of JObject: result = n.fields.len
else: nil else: discard
proc `[]`*(node: PJsonNode, name: string): PJsonNode = proc `[]`*(node: PJsonNode, name: string): PJsonNode =
## Gets a field from a `JObject`. Returns nil if the key is not found. ## Gets a field from a `JObject`. Returns nil if the key is not found.
@ -646,6 +646,7 @@ proc hasKey*(node: PJsonNode, key: string): bool =
assert(node.kind == JObject) assert(node.kind == JObject)
for k, item in items(node.fields): for k, item in items(node.fields):
if k == key: return true if k == key: return true
proc existsKey*(node: PJsonNode, key: string): bool {.deprecated.} = node.hasKey(key) proc existsKey*(node: PJsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
## Deprecated for `hasKey` ## Deprecated for `hasKey`

View file

@ -329,7 +329,7 @@ when defined(Windows) and not defined(useNimRtl):
handle: THandle handle: THandle
atTheEnd: bool atTheEnd: bool
proc hsClose(s: PStream) = nil # nothing to do here proc hsClose(s: PStream) = discard # nothing to do here
proc hsAtEnd(s: PStream): bool = return PFileHandleStream(s).atTheEnd proc hsAtEnd(s: PStream): bool = return PFileHandleStream(s).atTheEnd
proc hsReadData(s: PStream, buffer: pointer, bufLen: int): int = proc hsReadData(s: PStream, buffer: pointer, bufLen: int): int =

View file

@ -370,7 +370,7 @@ iterator interpolatedFragments*(s: string): tuple[kind: TInterpolatedKind,
of '\0': of '\0':
raise newException(EInvalidValue, raise newException(EInvalidValue,
"Expected closing '}': " & s[i..s.len]) "Expected closing '}': " & s[i..s.len])
else: nil else: discard
inc j inc j
inc i, 2 # skip ${ inc i, 2 # skip ${
kind = ikExpr kind = ikExpr

View file

@ -1523,7 +1523,7 @@ proc skip*(socket: TSocket) {.tags: [FReadIO], deprecated.} =
## **Deprecated since version 0.9.2**: This function is not safe for use. ## **Deprecated since version 0.9.2**: This function is not safe for use.
const bufSize = 1000 const bufSize = 1000
var buf = alloc(bufSize) var buf = alloc(bufSize)
while recv(socket, buf, bufSize) == bufSize: nil while recv(socket, buf, bufSize) == bufSize: discard
dealloc(buf) dealloc(buf)
proc skip*(socket: TSocket, size: int, timeout = -1) = proc skip*(socket: TSocket, size: int, timeout = -1) =

View file

@ -281,7 +281,7 @@ proc newFileStream*(filename: string, mode: TFileMode): PFileStream =
when true: when true:
nil discard
else: else:
type type
TFileHandle* = cint ## Operating system file handle TFileHandle* = cint ## Operating system file handle

View file

@ -304,7 +304,7 @@ proc countLines*(s: string): int {.noSideEffect,
if s[i+1] == '\l': inc i if s[i+1] == '\l': inc i
inc result inc result
of '\l': inc result of '\l': inc result
else: nil else: discard
inc i inc i
proc split*(s: string, seps: set[char] = Whitespace): seq[string] {. proc split*(s: string, seps: set[char] = Whitespace): seq[string] {.

View file

@ -698,7 +698,7 @@ proc format*(info: TTimeInfo, f: string): string =
of "ZZZ": of "ZZZ":
result.add(info.tzname) result.add(info.tzname)
of "": of "":
nil # Do nothing. discard
else: else:
raise newException(EInvalidValue, "Invalid format string: " & currentF) raise newException(EInvalidValue, "Invalid format string: " & currentF)

View file

@ -1029,11 +1029,7 @@ when not defined(useNimRtl):
dec(gch.recGcLock) dec(gch.recGcLock)
proc GC_setStrategy(strategy: TGC_Strategy) = proc GC_setStrategy(strategy: TGC_Strategy) =
case strategy discard
of gcThroughput: nil
of gcResponsiveness: nil
of gcOptimizeSpace: nil
of gcOptimizeTime: nil
proc GC_enableMarkAndSweep() = proc GC_enableMarkAndSweep() =
gch.cycleThreshold = InitialCycleThreshold gch.cycleThreshold = InitialCycleThreshold

View file

@ -3,7 +3,7 @@ News
==== ====
2013-XX-XX Version 0.9.4 released 2014-XX-XX Version 0.9.4 released
================================= =================================
@ -37,6 +37,7 @@ Changes affecting backwards compatibility
passed to shell, instead of just adding double quotes. passed to shell, instead of just adding double quotes.
- ``macros.dumpTree`` and ``macros.dumpLisp`` have been made ``immediate``, - ``macros.dumpTree`` and ``macros.dumpLisp`` have been made ``immediate``,
``dumpTreeImm`` and ``dumpLispImm`` are now deprecated. ``dumpTreeImm`` and ``dumpLispImm`` are now deprecated.
- The ``nil`` statement has been deprecated, use an empty ``discard`` instead.
Compiler Additions Compiler Additions
@ -68,7 +69,7 @@ Language Additions
fields at compile-time. fields at compile-time.
- The overload resolution now supports ``static[T]`` params that must be - The overload resolution now supports ``static[T]`` params that must be
evaluatable at compile-time. evaluatable at compile-time.
- Support for user-defined type classes have been added. - Support for user-defined type classes has been added.
Tools improvements Tools improvements