make tests green again
This commit is contained in:
parent
c38a608c90
commit
9364369c1f
9 changed files with 34 additions and 25 deletions
|
|
@ -291,21 +291,21 @@ proc genMagicCall(n: PNode; c: var Con; magicname: string; m: TMagic): PNode =
|
||||||
|
|
||||||
proc moveOrCopy(dest, ri: PNode; c: var Con): PNode =
|
proc moveOrCopy(dest, ri: PNode; c: var Con): PNode =
|
||||||
if ri.kind in constrExprs:
|
if ri.kind in constrExprs:
|
||||||
result = genSink(c, ri.typ, dest)
|
result = genSink(c, dest.typ, dest)
|
||||||
# watch out and no not transform 'ri' twice if it's a call:
|
# watch out and no not transform 'ri' twice if it's a call:
|
||||||
let ri2 = copyNode(ri)
|
let ri2 = copyNode(ri)
|
||||||
recurse(ri, ri2)
|
recurse(ri, ri2)
|
||||||
result.add ri2
|
result.add ri2
|
||||||
elif ri.kind == nkSym and isHarmlessVar(ri.sym, c):
|
elif ri.kind == nkSym and isHarmlessVar(ri.sym, c):
|
||||||
# Rule 3: `=sink`(x, z); wasMoved(z)
|
# Rule 3: `=sink`(x, z); wasMoved(z)
|
||||||
var snk = genSink(c, ri.typ, dest)
|
var snk = genSink(c, dest.typ, dest)
|
||||||
snk.add p(ri, c)
|
snk.add p(ri, c)
|
||||||
result = newTree(nkStmtList, snk, genMagicCall(ri, c, "wasMoved", mWasMoved))
|
result = newTree(nkStmtList, snk, genMagicCall(ri, c, "wasMoved", mWasMoved))
|
||||||
elif ri.kind == nkSym and isSinkParam(ri.sym):
|
elif ri.kind == nkSym and isSinkParam(ri.sym):
|
||||||
result = genSink(c, ri.typ, dest)
|
result = genSink(c, dest.typ, dest)
|
||||||
result.add destructiveMoveSink(ri, c)
|
result.add destructiveMoveSink(ri, c)
|
||||||
else:
|
else:
|
||||||
result = genCopy(c, ri.typ, dest)
|
result = genCopy(c, dest.typ, dest)
|
||||||
result.add p(ri, c)
|
result.add p(ri, c)
|
||||||
|
|
||||||
proc passCopyToSink(n: PNode; c: var Con): PNode =
|
proc passCopyToSink(n: PNode; c: var Con): PNode =
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,8 @@ proc processImplicits(conf: ConfigRef; implicits: seq[string], nodeKind: TNodeKi
|
||||||
|
|
||||||
const
|
const
|
||||||
imperativeCode = {low(TNodeKind)..high(TNodeKind)} - {nkTemplateDef, nkProcDef, nkMethodDef,
|
imperativeCode = {low(TNodeKind)..high(TNodeKind)} - {nkTemplateDef, nkProcDef, nkMethodDef,
|
||||||
nkMacroDef, nkConverterDef, nkIteratorDef, nkFuncDef}
|
nkMacroDef, nkConverterDef, nkIteratorDef, nkFuncDef, nkPragma,
|
||||||
|
nkExportStmt, nkExportExceptStmt, nkFromStmt, nkImportStmt, nkImportExceptStmt}
|
||||||
|
|
||||||
proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {.discardable.} =
|
proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {.discardable.} =
|
||||||
if graph.stopCompile(): return true
|
if graph.stopCompile(): return true
|
||||||
|
|
@ -206,10 +207,13 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {
|
||||||
rest = n
|
rest = n
|
||||||
break
|
break
|
||||||
sl.add n
|
sl.add n
|
||||||
|
#echo "-----\n", sl
|
||||||
if not processTopLevelStmt(sl, a): break
|
if not processTopLevelStmt(sl, a): break
|
||||||
if rest != nil:
|
if rest != nil:
|
||||||
|
#echo "-----\n", rest
|
||||||
if not processTopLevelStmt(rest, a): break
|
if not processTopLevelStmt(rest, a): break
|
||||||
else:
|
else:
|
||||||
|
#echo "----- single\n", n
|
||||||
if not processTopLevelStmt(n, a): break
|
if not processTopLevelStmt(n, a): break
|
||||||
closeParsers(p)
|
closeParsers(p)
|
||||||
if s.kind != llsStdIn: break
|
if s.kind != llsStdIn: break
|
||||||
|
|
|
||||||
|
|
@ -542,12 +542,20 @@ proc isImportSystemStmt(g: ModuleGraph; n: PNode): bool =
|
||||||
return true
|
return true
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
|
proc isEmptyTree(n: PNode): bool =
|
||||||
|
case n.kind
|
||||||
|
of nkStmtList:
|
||||||
|
for it in n:
|
||||||
|
if not isEmptyTree(it): return false
|
||||||
|
result = true
|
||||||
|
of nkEmpty, nkCommentStmt: result = true
|
||||||
|
else: result = false
|
||||||
|
|
||||||
proc semStmtAndGenerateGenerics(c: PContext, n: PNode): PNode =
|
proc semStmtAndGenerateGenerics(c: PContext, n: PNode): PNode =
|
||||||
if n.kind == nkDefer:
|
if n.kind == nkDefer:
|
||||||
localError(c.config, n.info, "defer statement not supported at top level")
|
localError(c.config, n.info, "defer statement not supported at top level")
|
||||||
if c.topStmts == 0 and not isImportSystemStmt(c.graph, n):
|
if c.topStmts == 0 and not isImportSystemStmt(c.graph, n):
|
||||||
if sfSystemModule notin c.module.flags and
|
if sfSystemModule notin c.module.flags and not isEmptyTree(n):
|
||||||
n.kind notin {nkEmpty, nkCommentStmt}:
|
|
||||||
c.importTable.addSym c.graph.systemModule # import the "System" identifier
|
c.importTable.addSym c.graph.systemModule # import the "System" identifier
|
||||||
importAllSymbols(c, c.graph.systemModule)
|
importAllSymbols(c, c.graph.systemModule)
|
||||||
inc c.topStmts
|
inc c.topStmts
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,8 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
if c.c.config.selectedGC == gcDestructors:
|
if c.c.config.selectedGC == gcDestructors:
|
||||||
discard considerOverloadedOp(c, t, body, x, y)
|
discard considerOverloadedOp(c, t, body, x, y)
|
||||||
elif tfHasAsgn in t.flags:
|
elif tfHasAsgn in t.flags:
|
||||||
body.add newSeqCall(c.c, x, y)
|
if c.kind != attachedDestructor:
|
||||||
|
body.add newSeqCall(c.c, x, y)
|
||||||
let i = declareCounter(c, body, firstOrd(c.c.config, t))
|
let i = declareCounter(c, body, firstOrd(c.c.config, t))
|
||||||
let whileLoop = genWhileLoop(c, i, x)
|
let whileLoop = genWhileLoop(c, i, x)
|
||||||
let elemType = t.lastSon
|
let elemType = t.lastSon
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim check $file"
|
cmd: "nim check $file"
|
||||||
errormsg: "'m' has unspecified generic parameters"
|
errormsg: "'t' has unspecified generic parameters"
|
||||||
nimout: '''
|
nimout: '''
|
||||||
t5167_5.nim(20, 9) Error: 't' has unspecified generic parameters
|
t5167_5.nim(20, 9) Error: 't' has unspecified generic parameters
|
||||||
t5167_5.nim(21, 5) Error: 't' has unspecified generic parameters
|
|
||||||
t5167_5.nim(23, 9) Error: 'm' has unspecified generic parameters
|
|
||||||
t5167_5.nim(24, 5) Error: 'm' has unspecified generic parameters
|
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template t[B]() =
|
template t[B]() =
|
||||||
echo "foo1"
|
echo "foo1"
|
||||||
|
|
||||||
macro m[T]: stmt = nil
|
macro m[T]: untyped = nil
|
||||||
|
|
||||||
proc bar(x: proc (x: int)) =
|
proc bar(x: proc (x: int)) =
|
||||||
echo "bar"
|
echo "bar"
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ proc noret1*(i: int) {.noreturn.} =
|
||||||
proc noret2*(i: int): void {.noreturn.} =
|
proc noret2*(i: int): void {.noreturn.} =
|
||||||
echo i
|
echo i
|
||||||
|
|
||||||
noret1(1)
|
if true: noret1(1)
|
||||||
noret2(2)
|
if true: noret2(2)
|
||||||
|
|
||||||
var p {.used.}: proc(i: int): int
|
var p {.used.}: proc(i: int): int
|
||||||
doAssert(not compiles(
|
doAssert(not compiles(
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ echo callWithFoo(0)
|
||||||
echo(CA+CD)
|
echo(CA+CD)
|
||||||
echo useTypes(TA(x:TB(x:1)), 2)
|
echo useTypes(TA(x:TB(x:1)), 2)
|
||||||
second(0)
|
second(0)
|
||||||
|
|
||||||
template callWithFoo(arg: untyped): untyped =
|
template callWithFoo(arg: untyped): untyped =
|
||||||
foo(arg)
|
foo(arg)
|
||||||
|
|
||||||
proc first(i: int): void
|
proc first(i: int): void
|
||||||
|
|
||||||
proc second(i: int): void =
|
proc second(i: int): void =
|
||||||
|
|
@ -35,7 +35,7 @@ type
|
||||||
type
|
type
|
||||||
TCyclicA = ref object
|
TCyclicA = ref object
|
||||||
x: TDoubleCyclic
|
x: TDoubleCyclic
|
||||||
|
|
||||||
type
|
type
|
||||||
TCyclicB = ref object
|
TCyclicB = ref object
|
||||||
x: TDoubleCyclic
|
x: TDoubleCyclic
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''3030
|
output: '''0
|
||||||
true
|
true
|
||||||
3'''
|
3'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template arithOps: untyped = (`+` | `-` | `*`)
|
template arithOps: untyped = (`+` | `-` | `*`)
|
||||||
template testOr{ (arithOps{f})(a, b) }(a, b, f: untyped): untyped = f(a+1, b)
|
template testOr{ (arithOps{f})(a, b) }(a, b, f: untyped): untyped = f(a mod 10, b)
|
||||||
|
|
||||||
let xx = 10
|
let xx = 10
|
||||||
echo 10*xx
|
echo 10*xx
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,4 @@ errormsg: "invalid type: 'object' for var"
|
||||||
line: 6
|
line: 6
|
||||||
"""
|
"""
|
||||||
|
|
||||||
var a: object a: int
|
var a: object
|
||||||
# or
|
|
||||||
var b: ref object a: int
|
|
||||||
# or
|
|
||||||
var c: ptr object a: int
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue