make tests green again
This commit is contained in:
parent
3af5a5d9e3
commit
feef109e60
16 changed files with 65 additions and 52 deletions
|
|
@ -61,6 +61,7 @@ type
|
||||||
proc initIdentIter*(ti: var TIdentIter, tab: TStrTable, s: PIdent): PSym
|
proc initIdentIter*(ti: var TIdentIter, tab: TStrTable, s: PIdent): PSym
|
||||||
proc nextIdentIter*(ti: var TIdentIter, tab: TStrTable): PSym
|
proc nextIdentIter*(ti: var TIdentIter, tab: TStrTable): PSym
|
||||||
|
|
||||||
|
when declared(echo):
|
||||||
# these are for debugging only: They are not really deprecated, but I want
|
# these are for debugging only: They are not really deprecated, but I want
|
||||||
# the warning so that release versions do not contain debugging statements:
|
# the warning so that release versions do not contain debugging statements:
|
||||||
proc debug*(conf: ConfigRef; n: PSym) {.deprecated.}
|
proc debug*(conf: ConfigRef; n: PSym) {.deprecated.}
|
||||||
|
|
@ -445,6 +446,7 @@ proc debugTree(conf: ConfigRef; n: PNode, indent: int, maxRecDepth: int;
|
||||||
addf(result, "$N$1]", [istr])
|
addf(result, "$N$1]", [istr])
|
||||||
addf(result, "$N$1}", [rspaces(indent)])
|
addf(result, "$N$1}", [rspaces(indent)])
|
||||||
|
|
||||||
|
when declared(echo):
|
||||||
proc debug(conf: ConfigRef; n: PSym) =
|
proc debug(conf: ConfigRef; n: PSym) =
|
||||||
if n == nil:
|
if n == nil:
|
||||||
echo("null")
|
echo("null")
|
||||||
|
|
|
||||||
|
|
@ -912,7 +912,7 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType;
|
||||||
var typename = typeToString(if origType.typeInst != nil: origType.typeInst
|
var typename = typeToString(if origType.typeInst != nil: origType.typeInst
|
||||||
else: origType, preferName)
|
else: origType, preferName)
|
||||||
if typename == "ref object" and origType.skipTypes(skipPtrs).sym != nil:
|
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",
|
addf(m.s[cfsTypeInit3], "$1.name = $2;$n",
|
||||||
[name, makeCstring typename])
|
[name, makeCstring typename])
|
||||||
discard cgsym(m, "nimTypeRoot")
|
discard cgsym(m, "nimTypeRoot")
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ proc methodDef*(g: ModuleGraph; s: PSym, fromCache: bool) =
|
||||||
# internalError(s.info, "no method dispatcher found")
|
# internalError(s.info, "no method dispatcher found")
|
||||||
if witness != nil:
|
if witness != nil:
|
||||||
localError(g.config, s.info, "invalid declaration order; cannot attach '" & s.name.s &
|
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:
|
elif sfBase notin s.flags:
|
||||||
message(g.config, s.info, warnUseBase)
|
message(g.config, s.info, warnUseBase)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ proc echoCfg*(c: ControlFlowGraph; start=0; last = -1) {.deprecated.} =
|
||||||
## echos the ControlFlowGraph for debugging purposes.
|
## echos the ControlFlowGraph for debugging purposes.
|
||||||
var buf = ""
|
var buf = ""
|
||||||
codeListing(c, buf, start, last)
|
codeListing(c, buf, start, last)
|
||||||
|
when declared(echo):
|
||||||
echo buf
|
echo buf
|
||||||
|
|
||||||
proc forkI(c: var Con; n: PNode): TPosition =
|
proc forkI(c: var Con; n: PNode): TPosition =
|
||||||
|
|
|
||||||
|
|
@ -734,6 +734,7 @@ proc callCCompiler*(conf: ConfigRef; projectfile: string) =
|
||||||
var cmds: TStringSeq = @[]
|
var cmds: TStringSeq = @[]
|
||||||
var prettyCmds: TStringSeq = @[]
|
var prettyCmds: TStringSeq = @[]
|
||||||
let prettyCb = proc (idx: int) =
|
let prettyCb = proc (idx: int) =
|
||||||
|
when declared(echo):
|
||||||
echo prettyCmds[idx]
|
echo prettyCmds[idx]
|
||||||
compileCFile(conf, conf.toCompile, script, cmds, prettyCmds)
|
compileCFile(conf, conf.toCompile, script, cmds, prettyCmds)
|
||||||
if optCompileOnly notin conf.globalOptions:
|
if optCompileOnly notin conf.globalOptions:
|
||||||
|
|
@ -846,6 +847,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
||||||
add(prettyCmds, "CC: " & name)
|
add(prettyCmds, "CC: " & name)
|
||||||
|
|
||||||
let prettyCb = proc (idx: int) =
|
let prettyCb = proc (idx: int) =
|
||||||
|
when declared(echo):
|
||||||
echo prettyCmds[idx]
|
echo prettyCmds[idx]
|
||||||
execCmdsInParallel(conf, cmds, prettyCb)
|
execCmdsInParallel(conf, cmds, prettyCb)
|
||||||
|
|
||||||
|
|
@ -853,6 +855,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
||||||
doAssert linkCmd.kind == JString
|
doAssert linkCmd.kind == JString
|
||||||
execLinkCmd(conf, linkCmd.getStr)
|
execLinkCmd(conf, linkCmd.getStr)
|
||||||
except:
|
except:
|
||||||
|
when declared(echo):
|
||||||
echo getCurrentException().getStackTrace()
|
echo getCurrentException().getStackTrace()
|
||||||
quit "error evaluating JSON file: " & jsonFile
|
quit "error evaluating JSON file: " & jsonFile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ proc markAsClosure(g: ModuleGraph; owner: PSym; n: PNode) =
|
||||||
let s = n.sym
|
let s = n.sym
|
||||||
if illegalCapture(s):
|
if illegalCapture(s):
|
||||||
localError(g.config, n.info, "illegal capture '$1' of type <$2> which is declared here: $3" %
|
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}:
|
elif owner.typ.callConv notin {ccClosure, ccDefault}:
|
||||||
localError(g.config, n.info, "illegal capture '$1' because '$2' has the calling convention: <$3>" %
|
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]])
|
[s.name.s, owner.name.s, CallingConvToStr[owner.typ.callConv]])
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ proc searchInScopes*(c: PContext, s: PIdent): PSym =
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
|
when declared(echo):
|
||||||
proc debugScopes*(c: PContext; limit=0) {.deprecated.} =
|
proc debugScopes*(c: PContext; limit=0) {.deprecated.} =
|
||||||
var i = 0
|
var i = 0
|
||||||
for scope in walkScopes(c.currentScope):
|
for scope in walkScopes(c.currentScope):
|
||||||
|
|
@ -147,10 +148,10 @@ type
|
||||||
scope*: PScope
|
scope*: PScope
|
||||||
inSymChoice: IntSet
|
inSymChoice: IntSet
|
||||||
|
|
||||||
proc getSymRepr*(s: PSym): string =
|
proc getSymRepr*(conf: ConfigRef; s: PSym): string =
|
||||||
case s.kind
|
case s.kind
|
||||||
of skProc, skFunc, skMethod, skConverter, skIterator:
|
of skProc, skFunc, skMethod, skConverter, skIterator:
|
||||||
result = getProcHeader(s)
|
result = getProcHeader(conf, s)
|
||||||
else:
|
else:
|
||||||
result = s.name.s
|
result = s.name.s
|
||||||
|
|
||||||
|
|
@ -164,7 +165,8 @@ proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope) =
|
||||||
# too many 'implementation of X' errors are annoying
|
# too many 'implementation of X' errors are annoying
|
||||||
# and slow 'suggest' down:
|
# and slow 'suggest' down:
|
||||||
if missingImpls == 0:
|
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
|
inc missingImpls
|
||||||
elif {sfUsed, sfExported} * s.flags == {} and optHints in s.options:
|
elif {sfUsed, sfExported} * s.flags == {} and optHints in s.options:
|
||||||
if s.kind notin {skForVar, skParam, skMethod, skUnknown, skGenericParam}:
|
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.
|
# maybe they can be made skGenericParam as well.
|
||||||
if s.typ != nil and tfImplicitTypeParam notin s.typ.flags and
|
if s.typ != nil and tfImplicitTypeParam notin s.typ.flags and
|
||||||
s.typ.kind != tyGenericParam:
|
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)
|
s = nextIter(it, scope.symbols)
|
||||||
|
|
||||||
proc wrongRedefinition*(c: PContext; info: TLineInfo, s: string) =
|
proc wrongRedefinition*(c: PContext; info: TLineInfo, s: string) =
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ proc registerNimScriptSymbol*(g: ModuleGraph; s: PSym) =
|
||||||
strTableAdd(g.exposed, s)
|
strTableAdd(g.exposed, s)
|
||||||
else:
|
else:
|
||||||
localError(g.config, s.info,
|
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 =
|
proc getNimScriptSymbol*(g: ModuleGraph; name: string): PSym =
|
||||||
strTableGet(g.exposed, getIdent(name))
|
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 `$`*(conf: ConfigRef; info: TLineInfo): string = toFileLineCol(conf, info)
|
||||||
|
|
||||||
|
proc `$`*(info: TLineInfo): string {.error.} = discard
|
||||||
|
|
||||||
proc `??`* (conf: ConfigRef; info: TLineInfo, filename: string): bool =
|
proc `??`* (conf: ConfigRef; info: TLineInfo, filename: string): bool =
|
||||||
# only for debugging purposes
|
# only for debugging purposes
|
||||||
result = filename in toFilename(conf, info)
|
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):
|
if (sfExported notin result.flags) and (sfExported in fn.flags):
|
||||||
let message = ("public implementation '$1' has non-public " &
|
let message = ("public implementation '$1' has non-public " &
|
||||||
"forward declaration in $2") %
|
"forward declaration in $2") %
|
||||||
[getProcHeader(result), $result.info]
|
[getProcHeader(c.config, result), c.config$result.info]
|
||||||
localError(c.config, fn.info, message)
|
localError(c.config, fn.info, message)
|
||||||
return
|
return
|
||||||
of paramsIncompatible:
|
of paramsIncompatible:
|
||||||
|
|
|
||||||
|
|
@ -792,6 +792,7 @@ proc findSomeWhere(id: int) =
|
||||||
if rd != nil:
|
if rd != nil:
|
||||||
var d = iiTableGet(rd.index.tab, id)
|
var d = iiTableGet(rd.index.tab, id)
|
||||||
if d != InvalidKey:
|
if d != InvalidKey:
|
||||||
|
when declared(echo):
|
||||||
echo "found id ", id, " in ", gMods[i].filename
|
echo "found id ", id, " in ", gMods[i].filename
|
||||||
|
|
||||||
proc getReader(moduleId: int): PRodReader =
|
proc getReader(moduleId: int): PRodReader =
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
|
||||||
add(candidates, renderTree(err.sym.ast,
|
add(candidates, renderTree(err.sym.ast,
|
||||||
{renderNoBody, renderNoComments, renderNoPragmas}))
|
{renderNoBody, renderNoComments, renderNoPragmas}))
|
||||||
else:
|
else:
|
||||||
add(candidates, err.sym.getProcHeader(prefer))
|
add(candidates, getProcHeader(c.config, err.sym, prefer))
|
||||||
add(candidates, "\n")
|
add(candidates, "\n")
|
||||||
if err.firstMismatch != 0 and n.len > 1:
|
if err.firstMismatch != 0 and n.len > 1:
|
||||||
let cond = n.len > 2
|
let cond = n.len > 2
|
||||||
|
|
@ -344,7 +344,8 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||||
add(args, ")")
|
add(args, ")")
|
||||||
|
|
||||||
localError(c.config, n.info, errAmbiguousCallXYZ % [
|
localError(c.config, n.info, errAmbiguousCallXYZ % [
|
||||||
getProcHeader(result.calleeSym), getProcHeader(alt.calleeSym),
|
getProcHeader(c.config, result.calleeSym),
|
||||||
|
getProcHeader(c.config, alt.calleeSym),
|
||||||
args])
|
args])
|
||||||
|
|
||||||
proc instGenericConvertersArg*(c: PContext, a: PNode, x: TCandidate) =
|
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"
|
result.typ.typeToString & "' and has to be discarded"
|
||||||
if result.info.line != n.info.line or
|
if result.info.line != n.info.line or
|
||||||
result.info.fileIndex != n.info.fileIndex:
|
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:
|
if result.typ.kind == tyProc:
|
||||||
s.add "; for a function call use ()"
|
s.add "; for a function call use ()"
|
||||||
localError(c.config, n.info, s)
|
localError(c.config, n.info, s)
|
||||||
|
|
@ -696,7 +696,8 @@ proc handleForLoopMacro(c: PContext; n: PNode): PNode =
|
||||||
match = symx
|
match = symx
|
||||||
else:
|
else:
|
||||||
localError(c.config, n.info, errAmbiguousCallXYZ % [
|
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)
|
symx = nextOverloadIter(o, c, headSymbol)
|
||||||
|
|
||||||
if match == nil: return
|
if match == nil: return
|
||||||
|
|
@ -832,7 +833,7 @@ proc typeSectionLeftSidePass(c: PContext, n: PNode) =
|
||||||
typsym.info = s.info
|
typsym.info = s.info
|
||||||
else:
|
else:
|
||||||
localError(c.config, name.info, "cannot complete type '" & s.name.s & "' twice; " &
|
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
|
s = typsym
|
||||||
# add it here, so that recursive types are possible:
|
# add it here, so that recursive types are possible:
|
||||||
if sfGenSym notin s.flags: addInterfaceDecl(c, s)
|
if sfGenSym notin s.flags: addInterfaceDecl(c, s)
|
||||||
|
|
@ -1541,7 +1542,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||||
# linking names do agree:
|
# linking names do agree:
|
||||||
if proto.typ.callConv != s.typ.callConv or proto.typ.flags < s.typ.flags:
|
if proto.typ.callConv != s.typ.callConv or proto.typ.flags < s.typ.flags:
|
||||||
localError(c.config, n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProcX %
|
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:
|
if sfForward notin proto.flags:
|
||||||
wrongRedefinition(c, n.info, proto.name.s)
|
wrongRedefinition(c, n.info, proto.name.s)
|
||||||
excl(proto.flags, sfForward)
|
excl(proto.flags, sfForward)
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ proc complexDisambiguation(a, b: PType): int =
|
||||||
result = x - y
|
result = x - y
|
||||||
|
|
||||||
proc writeMatches*(c: TCandidate) =
|
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 " exact matches: ", c.exactMatches
|
||||||
echo " generic matches: ", c.genericMatches
|
echo " generic matches: ", c.genericMatches
|
||||||
echo " subtype matches: ", c.subtypeMatches
|
echo " subtype matches: ", c.subtypeMatches
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ proc isIntLit*(t: PType): bool {.inline.} =
|
||||||
proc isFloatLit*(t: PType): bool {.inline.} =
|
proc isFloatLit*(t: PType): bool {.inline.} =
|
||||||
result = t.kind == tyFloat and t.n != nil and t.n.kind == nkFloatLit
|
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 & '('
|
result = sym.owner.name.s & '.' & sym.name.s & '('
|
||||||
var n = sym.typ.n
|
var n = sym.typ.n
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
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:
|
if n.sons[0].typ != nil:
|
||||||
result.add(": " & typeToString(n.sons[0].typ, prefer))
|
result.add(": " & typeToString(n.sons[0].typ, prefer))
|
||||||
result.add "[declared in "
|
result.add "[declared in "
|
||||||
result.add($sym.info)
|
result.add(conf$sym.info)
|
||||||
result.add "]"
|
result.add "]"
|
||||||
|
|
||||||
proc elemType*(t: PType): PType =
|
proc elemType*(t: PType): PType =
|
||||||
|
|
|
||||||
|
|
@ -832,7 +832,7 @@ elif not defined(useNimRtl):
|
||||||
|
|
||||||
# Parent process. Copy process information.
|
# Parent process. Copy process information.
|
||||||
if poEchoCmd in options:
|
if poEchoCmd in options:
|
||||||
echo(command, " ", join(args, " "))
|
when declared(echo): echo(command, " ", join(args, " "))
|
||||||
result.id = pid
|
result.id = pid
|
||||||
result.exitFlag = false
|
result.exitFlag = false
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue