diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-05-18 20:53:41 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-18 20:53:41 +0200 |
commit | feef109e60fd33ff350cbcf82298a7cae83bbd72 (patch) | |
tree | 8ffd0028e2401765a6a7d6100d5731bd9f3f0425 | |
parent | 3af5a5d9e3604a903505a04d2747c04986e6042f (diff) | |
download | Nim-feef109e60fd33ff350cbcf82298a7cae83bbd72.tar.gz |
make tests green again
-rw-r--r-- | compiler/astalgo.nim | 40 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 2 | ||||
-rw-r--r-- | compiler/cgmeth.nim | 2 | ||||
-rw-r--r-- | compiler/dfa.nim | 3 | ||||
-rw-r--r-- | compiler/extccomp.nim | 9 | ||||
-rw-r--r-- | compiler/lambdalifting.nim | 2 | ||||
-rw-r--r-- | compiler/lookups.nim | 28 | ||||
-rw-r--r-- | compiler/magicsys.nim | 2 | ||||
-rw-r--r-- | compiler/msgs.nim | 2 | ||||
-rw-r--r-- | compiler/procfind.nim | 2 | ||||
-rw-r--r-- | compiler/rodread.nim | 3 | ||||
-rw-r--r-- | compiler/semcall.nim | 5 | ||||
-rw-r--r-- | compiler/semstmts.nim | 9 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 2 | ||||
-rw-r--r-- | compiler/types.nim | 4 | ||||
-rw-r--r-- | lib/pure/osproc.nim | 2 |
16 files changed, 65 insertions, 52 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 2ad1e24cb..1b6417964 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -61,11 +61,12 @@ type proc initIdentIter*(ti: var TIdentIter, tab: TStrTable, s: PIdent): PSym proc nextIdentIter*(ti: var TIdentIter, tab: TStrTable): PSym -# these are for debugging only: They are not really deprecated, but I want -# the warning so that release versions do not contain debugging statements: -proc debug*(conf: ConfigRef; n: PSym) {.deprecated.} -proc debug*(conf: ConfigRef; n: PType) {.deprecated.} -proc debug*(conf: ConfigRef; n: PNode) {.deprecated.} +when declared(echo): + # these are for debugging only: They are not really deprecated, but I want + # the warning so that release versions do not contain debugging statements: + proc debug*(conf: ConfigRef; n: PSym) {.deprecated.} + proc debug*(conf: ConfigRef; n: PType) {.deprecated.} + proc debug*(conf: ConfigRef; n: PNode) {.deprecated.} template mdbg*: bool {.dirty.} = when compiles(c.module): @@ -445,22 +446,23 @@ proc debugTree(conf: ConfigRef; n: PNode, indent: int, maxRecDepth: int; addf(result, "$N$1]", [istr]) addf(result, "$N$1}", [rspaces(indent)]) -proc debug(conf: ConfigRef; n: PSym) = - if n == nil: - echo("null") - elif n.kind == skUnknown: - echo("skUnknown") - else: - #writeLine(stdout, $symToYaml(n, 0, 1)) - echo("$1_$2: $3, $4, $5, $6" % [ - n.name.s, $n.id, $flagsToStr(n.flags), $flagsToStr(n.loc.flags), - $lineInfoToStr(conf, n.info), $n.kind]) +when declared(echo): + proc debug(conf: ConfigRef; n: PSym) = + if n == nil: + echo("null") + elif n.kind == skUnknown: + echo("skUnknown") + else: + #writeLine(stdout, $symToYaml(n, 0, 1)) + echo("$1_$2: $3, $4, $5, $6" % [ + n.name.s, $n.id, $flagsToStr(n.flags), $flagsToStr(n.loc.flags), + $lineInfoToStr(conf, n.info), $n.kind]) -proc debug(conf: ConfigRef; n: PType) = - echo($debugType(conf, n)) + proc debug(conf: ConfigRef; n: PType) = + echo($debugType(conf, n)) -proc debug(conf: ConfigRef; n: PNode) = - echo($debugTree(conf, n, 0, 100)) + proc debug(conf: ConfigRef; n: PNode) = + echo($debugTree(conf, n, 0, 100)) proc nextTry(h, maxHash: Hash): Hash = result = ((5 * h) + 1) and maxHash diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 1a7cd1dad..d0433f9ae 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -912,7 +912,7 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType; var typename = typeToString(if origType.typeInst != nil: origType.typeInst else: origType, preferName) if typename == "ref object" and origType.skipTypes(skipPtrs).sym != nil: - typename = "anon ref object from " & $origType.skipTypes(skipPtrs).sym.info + typename = "anon ref object from " & m.config$origType.skipTypes(skipPtrs).sym.info addf(m.s[cfsTypeInit3], "$1.name = $2;$n", [name, makeCstring typename]) discard cgsym(m, "nimTypeRoot") diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim index c739381bb..da3ffaa61 100644 --- a/compiler/cgmeth.nim +++ b/compiler/cgmeth.nim @@ -184,7 +184,7 @@ proc methodDef*(g: ModuleGraph; s: PSym, fromCache: bool) = # internalError(s.info, "no method dispatcher found") if witness != nil: localError(g.config, s.info, "invalid declaration order; cannot attach '" & s.name.s & - "' to method defined here: " & $witness.info) + "' to method defined here: " & g.config$witness.info) elif sfBase notin s.flags: message(g.config, s.info, warnUseBase) diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 95fbe2872..aab1d9b4b 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -87,7 +87,8 @@ proc echoCfg*(c: ControlFlowGraph; start=0; last = -1) {.deprecated.} = ## echos the ControlFlowGraph for debugging purposes. var buf = "" codeListing(c, buf, start, last) - echo buf + when declared(echo): + echo buf proc forkI(c: var Con; n: PNode): TPosition = result = TPosition(c.code.len) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 45db8d6bf..23db9cbe1 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -734,7 +734,8 @@ proc callCCompiler*(conf: ConfigRef; projectfile: string) = var cmds: TStringSeq = @[] var prettyCmds: TStringSeq = @[] let prettyCb = proc (idx: int) = - echo prettyCmds[idx] + when declared(echo): + echo prettyCmds[idx] compileCFile(conf, conf.toCompile, script, cmds, prettyCmds) if optCompileOnly notin conf.globalOptions: execCmdsInParallel(conf, cmds, prettyCb) @@ -846,14 +847,16 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: string) = add(prettyCmds, "CC: " & name) let prettyCb = proc (idx: int) = - echo prettyCmds[idx] + when declared(echo): + echo prettyCmds[idx] execCmdsInParallel(conf, cmds, prettyCb) let linkCmd = data["linkcmd"] doAssert linkCmd.kind == JString execLinkCmd(conf, linkCmd.getStr) except: - echo getCurrentException().getStackTrace() + when declared(echo): + echo getCurrentException().getStackTrace() quit "error evaluating JSON file: " & jsonFile proc genMappingFiles(conf: ConfigRef; list: CFileList): Rope = diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 2789e4b8f..f9795a766 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -279,7 +279,7 @@ proc markAsClosure(g: ModuleGraph; owner: PSym; n: PNode) = let s = n.sym if illegalCapture(s): localError(g.config, n.info, "illegal capture '$1' of type <$2> which is declared here: $3" % - [s.name.s, typeToString(s.typ), $s.info]) + [s.name.s, typeToString(s.typ), g.config$s.info]) elif owner.typ.callConv notin {ccClosure, ccDefault}: localError(g.config, n.info, "illegal capture '$1' because '$2' has the calling convention: <$3>" % [s.name.s, owner.name.s, CallingConvToStr[owner.typ.callConv]]) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 46617680e..a67b027cb 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -100,15 +100,16 @@ proc searchInScopes*(c: PContext, s: PIdent): PSym = if result != nil: return result = nil -proc debugScopes*(c: PContext; limit=0) {.deprecated.} = - var i = 0 - for scope in walkScopes(c.currentScope): - echo "scope ", i - for h in 0 .. high(scope.symbols.data): - if scope.symbols.data[h] != nil: - echo scope.symbols.data[h].name.s - if i == limit: break - inc i +when declared(echo): + proc debugScopes*(c: PContext; limit=0) {.deprecated.} = + var i = 0 + for scope in walkScopes(c.currentScope): + echo "scope ", i + for h in 0 .. high(scope.symbols.data): + if scope.symbols.data[h] != nil: + echo scope.symbols.data[h].name.s + if i == limit: break + inc i proc searchInScopes*(c: PContext, s: PIdent, filter: TSymKinds): PSym = for scope in walkScopes(c.currentScope): @@ -147,10 +148,10 @@ type scope*: PScope inSymChoice: IntSet -proc getSymRepr*(s: PSym): string = +proc getSymRepr*(conf: ConfigRef; s: PSym): string = case s.kind of skProc, skFunc, skMethod, skConverter, skIterator: - result = getProcHeader(s) + result = getProcHeader(conf, s) else: result = s.name.s @@ -164,7 +165,8 @@ proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope) = # too many 'implementation of X' errors are annoying # and slow 'suggest' down: if missingImpls == 0: - localError(c.config, s.info, "implementation of '$1' expected" % getSymRepr(s)) + localError(c.config, s.info, "implementation of '$1' expected" % + getSymRepr(c.config, s)) inc missingImpls elif {sfUsed, sfExported} * s.flags == {} and optHints in s.options: if s.kind notin {skForVar, skParam, skMethod, skUnknown, skGenericParam}: @@ -172,7 +174,7 @@ proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope) = # maybe they can be made skGenericParam as well. if s.typ != nil and tfImplicitTypeParam notin s.typ.flags and s.typ.kind != tyGenericParam: - message(c.config, s.info, hintXDeclaredButNotUsed, getSymRepr(s)) + message(c.config, s.info, hintXDeclaredButNotUsed, getSymRepr(c.config, s)) s = nextIter(it, scope.symbols) proc wrongRedefinition*(c: PContext; info: TLineInfo, s: string) = diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim index 3accf90b4..2f021743e 100644 --- a/compiler/magicsys.nim +++ b/compiler/magicsys.nim @@ -187,7 +187,7 @@ proc registerNimScriptSymbol*(g: ModuleGraph; s: PSym) = strTableAdd(g.exposed, s) else: localError(g.config, s.info, - "symbol conflicts with other .exportNims symbol at: " & $conflict.info) + "symbol conflicts with other .exportNims symbol at: " & g.config$conflict.info) proc getNimScriptSymbol*(g: ModuleGraph; name: string): PSym = strTableGet(g.exposed, getIdent(name)) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 9824f7c1c..151291ffb 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -282,6 +282,8 @@ proc toFileLineCol*(conf: ConfigRef; info: TLineInfo): string {.inline.} = proc `$`*(conf: ConfigRef; info: TLineInfo): string = toFileLineCol(conf, info) +proc `$`*(info: TLineInfo): string {.error.} = discard + proc `??`* (conf: ConfigRef; info: TLineInfo, filename: string): bool = # only for debugging purposes result = filename in toFilename(conf, info) diff --git a/compiler/procfind.nim b/compiler/procfind.nim index 042947e72..3f47e7e8a 100644 --- a/compiler/procfind.nim +++ b/compiler/procfind.nim @@ -73,7 +73,7 @@ proc searchForProcNew(c: PContext, scope: PScope, fn: PSym): PSym = if (sfExported notin result.flags) and (sfExported in fn.flags): let message = ("public implementation '$1' has non-public " & "forward declaration in $2") % - [getProcHeader(result), $result.info] + [getProcHeader(c.config, result), c.config$result.info] localError(c.config, fn.info, message) return of paramsIncompatible: diff --git a/compiler/rodread.nim b/compiler/rodread.nim index 3eeee1127..9c834a410 100644 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -792,7 +792,8 @@ proc findSomeWhere(id: int) = if rd != nil: var d = iiTableGet(rd.index.tab, id) if d != InvalidKey: - echo "found id ", id, " in ", gMods[i].filename + when declared(echo): + echo "found id ", id, " in ", gMods[i].filename proc getReader(moduleId: int): PRodReader = # we can't index 'gMods' here as it's indexed by a *file index* which is not diff --git a/compiler/semcall.nim b/compiler/semcall.nim index e9a31d3d6..1de5a55cc 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -170,7 +170,7 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors): add(candidates, renderTree(err.sym.ast, {renderNoBody, renderNoComments, renderNoPragmas})) else: - add(candidates, err.sym.getProcHeader(prefer)) + add(candidates, getProcHeader(c.config, err.sym, prefer)) add(candidates, "\n") if err.firstMismatch != 0 and n.len > 1: let cond = n.len > 2 @@ -344,7 +344,8 @@ proc resolveOverloads(c: PContext, n, orig: PNode, add(args, ")") localError(c.config, n.info, errAmbiguousCallXYZ % [ - getProcHeader(result.calleeSym), getProcHeader(alt.calleeSym), + getProcHeader(c.config, result.calleeSym), + getProcHeader(c.config, alt.calleeSym), args]) proc instGenericConvertersArg*(c: PContext, a: PNode, x: TCandidate) = diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c0dc47b6f..055ac3425 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -144,7 +144,7 @@ proc discardCheck(c: PContext, result: PNode) = result.typ.typeToString & "' and has to be discarded" if result.info.line != n.info.line or result.info.fileIndex != n.info.fileIndex: - s.add "; start of expression here: " & $result.info + s.add "; start of expression here: " & c.config$result.info if result.typ.kind == tyProc: s.add "; for a function call use ()" localError(c.config, n.info, s) @@ -696,7 +696,8 @@ proc handleForLoopMacro(c: PContext; n: PNode): PNode = match = symx else: localError(c.config, n.info, errAmbiguousCallXYZ % [ - getProcHeader(match), getProcHeader(symx), $iterExpr]) + getProcHeader(c.config, match), + getProcHeader(c.config, symx), $iterExpr]) symx = nextOverloadIter(o, c, headSymbol) if match == nil: return @@ -832,7 +833,7 @@ proc typeSectionLeftSidePass(c: PContext, n: PNode) = typsym.info = s.info else: localError(c.config, name.info, "cannot complete type '" & s.name.s & "' twice; " & - "previous type completion was here: " & $typsym.info) + "previous type completion was here: " & c.config$typsym.info) s = typsym # add it here, so that recursive types are possible: if sfGenSym notin s.flags: addInterfaceDecl(c, s) @@ -1541,7 +1542,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, # linking names do agree: if proto.typ.callConv != s.typ.callConv or proto.typ.flags < s.typ.flags: localError(c.config, n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProcX % - ("'" & proto.name.s & "' from " & $proto.info)) + ("'" & proto.name.s & "' from " & c.config$proto.info)) if sfForward notin proto.flags: wrongRedefinition(c, n.info, proto.name.s) excl(proto.flags, sfForward) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index a83fe080b..8fdf10afb 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -253,7 +253,7 @@ proc complexDisambiguation(a, b: PType): int = result = x - y proc writeMatches*(c: TCandidate) = - echo "Candidate '", c.calleeSym.name.s, "' at ", c.calleeSym.info + echo "Candidate '", c.calleeSym.name.s, "' at ", c.c.config $ c.calleeSym.info echo " exact matches: ", c.exactMatches echo " generic matches: ", c.genericMatches echo " subtype matches: ", c.subtypeMatches diff --git a/compiler/types.nim b/compiler/types.nim index a3476a353..4b6cb105c 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -102,7 +102,7 @@ proc isIntLit*(t: PType): bool {.inline.} = proc isFloatLit*(t: PType): bool {.inline.} = result = t.kind == tyFloat and t.n != nil and t.n.kind == nkFloatLit -proc getProcHeader*(sym: PSym; prefer: TPreferedDesc = preferName): string = +proc getProcHeader*(conf: ConfigRef; sym: PSym; prefer: TPreferedDesc = preferName): string = result = sym.owner.name.s & '.' & sym.name.s & '(' var n = sym.typ.n for i in countup(1, sonsLen(n) - 1): @@ -118,7 +118,7 @@ proc getProcHeader*(sym: PSym; prefer: TPreferedDesc = preferName): string = if n.sons[0].typ != nil: result.add(": " & typeToString(n.sons[0].typ, prefer)) result.add "[declared in " - result.add($sym.info) + result.add(conf$sym.info) result.add "]" proc elemType*(t: PType): PType = diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 664446d54..e8bca4bdd 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -832,7 +832,7 @@ elif not defined(useNimRtl): # Parent process. Copy process information. if poEchoCmd in options: - echo(command, " ", join(args, " ")) + when declared(echo): echo(command, " ", join(args, " ")) result.id = pid result.exitFlag = false |