mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 14:25:23 +00:00
make tests green again
This commit is contained in:
@@ -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 =
|
||||
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:
|
||||
let ri2 = copyNode(ri)
|
||||
recurse(ri, ri2)
|
||||
result.add ri2
|
||||
elif ri.kind == nkSym and isHarmlessVar(ri.sym, c):
|
||||
# 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)
|
||||
result = newTree(nkStmtList, snk, genMagicCall(ri, c, "wasMoved", mWasMoved))
|
||||
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)
|
||||
else:
|
||||
result = genCopy(c, ri.typ, dest)
|
||||
result = genCopy(c, dest.typ, dest)
|
||||
result.add p(ri, c)
|
||||
|
||||
proc passCopyToSink(n: PNode; c: var Con): PNode =
|
||||
|
||||
@@ -127,7 +127,8 @@ proc processImplicits(conf: ConfigRef; implicits: seq[string], nodeKind: TNodeKi
|
||||
|
||||
const
|
||||
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.} =
|
||||
if graph.stopCompile(): return true
|
||||
@@ -206,10 +207,13 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {
|
||||
rest = n
|
||||
break
|
||||
sl.add n
|
||||
#echo "-----\n", sl
|
||||
if not processTopLevelStmt(sl, a): break
|
||||
if rest != nil:
|
||||
#echo "-----\n", rest
|
||||
if not processTopLevelStmt(rest, a): break
|
||||
else:
|
||||
#echo "----- single\n", n
|
||||
if not processTopLevelStmt(n, a): break
|
||||
closeParsers(p)
|
||||
if s.kind != llsStdIn: break
|
||||
|
||||
@@ -542,12 +542,20 @@ proc isImportSystemStmt(g: ModuleGraph; n: PNode): bool =
|
||||
return true
|
||||
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 =
|
||||
if n.kind == nkDefer:
|
||||
localError(c.config, n.info, "defer statement not supported at top level")
|
||||
if c.topStmts == 0 and not isImportSystemStmt(c.graph, n):
|
||||
if sfSystemModule notin c.module.flags and
|
||||
n.kind notin {nkEmpty, nkCommentStmt}:
|
||||
if sfSystemModule notin c.module.flags and not isEmptyTree(n):
|
||||
c.importTable.addSym c.graph.systemModule # import the "System" identifier
|
||||
importAllSymbols(c, c.graph.systemModule)
|
||||
inc c.topStmts
|
||||
|
||||
@@ -216,7 +216,8 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||
if c.c.config.selectedGC == gcDestructors:
|
||||
discard considerOverloadedOp(c, t, body, x, y)
|
||||
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 whileLoop = genWhileLoop(c, i, x)
|
||||
let elemType = t.lastSon
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
discard """
|
||||
cmd: "nim check $file"
|
||||
errormsg: "'m' has unspecified generic parameters"
|
||||
errormsg: "'t' has unspecified generic parameters"
|
||||
nimout: '''
|
||||
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]() =
|
||||
echo "foo1"
|
||||
|
||||
macro m[T]: stmt = nil
|
||||
macro m[T]: untyped = nil
|
||||
|
||||
proc bar(x: proc (x: int)) =
|
||||
echo "bar"
|
||||
|
||||
@@ -9,8 +9,8 @@ proc noret1*(i: int) {.noreturn.} =
|
||||
proc noret2*(i: int): void {.noreturn.} =
|
||||
echo i
|
||||
|
||||
noret1(1)
|
||||
noret2(2)
|
||||
if true: noret1(1)
|
||||
if true: noret2(2)
|
||||
|
||||
var p {.used.}: proc(i: int): int
|
||||
doAssert(not compiles(
|
||||
|
||||
@@ -14,10 +14,10 @@ echo callWithFoo(0)
|
||||
echo(CA+CD)
|
||||
echo useTypes(TA(x:TB(x:1)), 2)
|
||||
second(0)
|
||||
|
||||
|
||||
template callWithFoo(arg: untyped): untyped =
|
||||
foo(arg)
|
||||
|
||||
|
||||
proc first(i: int): void
|
||||
|
||||
proc second(i: int): void =
|
||||
@@ -35,7 +35,7 @@ type
|
||||
type
|
||||
TCyclicA = ref object
|
||||
x: TDoubleCyclic
|
||||
|
||||
|
||||
type
|
||||
TCyclicB = ref object
|
||||
x: TDoubleCyclic
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
discard """
|
||||
output: '''3030
|
||||
output: '''0
|
||||
true
|
||||
3'''
|
||||
"""
|
||||
|
||||
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
|
||||
echo 10*xx
|
||||
|
||||
@@ -3,8 +3,4 @@ errormsg: "invalid type: 'object' for var"
|
||||
line: 6
|
||||
"""
|
||||
|
||||
var a: object a: int
|
||||
# or
|
||||
var b: ref object a: int
|
||||
# or
|
||||
var c: ptr object a: int
|
||||
var a: object
|
||||
|
||||
Reference in New Issue
Block a user