mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
make tests green again
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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]])
|
||||
|
||||
@@ -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) =
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) =
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user