summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/semexprs.nim2
-rw-r--r--lib/pure/unittest.nim18
-rwxr-xr-xlib/system/threads.nim6
-rw-r--r--tests/compile/talias.nim2
-rwxr-xr-xtests/compile/tcan_inherit_generic.nim2
-rwxr-xr-xtests/compile/tcan_specialise_generic.nim2
-rwxr-xr-xtests/compile/tccgen1.nim2
-rwxr-xr-xtests/compile/tdumpast.nim3
-rw-r--r--tests/compile/tdumpast2.nim3
-rwxr-xr-xtests/compile/teval1.nim2
-rwxr-xr-xtests/compile/thallo.nim6
-rwxr-xr-xtests/compile/tmacro1.nim2
-rwxr-xr-xtests/compile/tmacrostmt.nim2
-rwxr-xr-xtests/compile/tobjcov.nim2
-rwxr-xr-xtests/compile/tobject2.nim2
-rwxr-xr-xtests/compile/tobjects.nim2
-rwxr-xr-xtests/compile/toop.nim2
-rwxr-xr-xtests/compile/tradix.nim4
-rwxr-xr-xtests/compile/tstrset.nim4
-rwxr-xr-xtests/compile/ttempl3.nim11
-rw-r--r--tests/reject/tind1.nim2
21 files changed, 42 insertions, 39 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 027cd0946..521de8c23 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -707,7 +707,7 @@ proc semExprNoType(c: PContext, n: PNode): PNode =
     result = isCallExpr(n) and n.sons[0].kind == nkSym and 
              sfDiscardable in n.sons[0].sym.flags
   result = semExpr(c, n)
-  if result.typ != nil and result.typ.kind != tyStmt:
+  if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}:
     if gCmd == cmdInteractive:
       result = buildEchoStmt(c, result)
     elif not ImplicitelyDiscardable(result) and result.typ.kind != tyError:
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index 7bfde7904..be5e19c23 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -31,19 +31,19 @@ var
   

   checkpoints: seq[string] = @[]

 

-template TestSetupIMPL*: stmt {.dirty.} = nil

-template TestTeardownIMPL*: stmt {.dirty.} = nil

+template TestSetupIMPL*: stmt {.immediate, dirty.} = nil

+template TestTeardownIMPL*: stmt {.immediate, dirty.} = nil

 

 proc shouldRun(testName: string): bool =

   result = true

 

-template suite*(name: expr, body: stmt): stmt {.dirty.} =

+template suite*(name: expr, body: stmt): stmt {.immediate, dirty.} =

   block:

-    template setup*(setupBody: stmt): stmt {.dirty.} =

-      template TestSetupIMPL: stmt {.dirty.} = setupBody

+    template setup*(setupBody: stmt): stmt {.immediate, dirty.} =

+      template TestSetupIMPL: stmt {.immediate, dirty.} = setupBody

 

-    template teardown*(teardownBody: stmt): stmt {.dirty.} =

-      template TestTeardownIMPL: stmt {.dirty.} = teardownBody

+    template teardown*(teardownBody: stmt): stmt {.immediate, dirty.} =

+      template TestTeardownIMPL: stmt {.immediate, dirty.} = teardownBody

 

     body

 

@@ -59,7 +59,7 @@ proc testDone(name: string, s: TTestStatus) =
     else:

       echo "[", $s, "] ", name, "\n"

   

-template test*(name: expr, body: stmt): stmt {.dirty.} =

+template test*(name: expr, body: stmt): stmt {.immediate, dirty.} =

   bind shouldRun, checkpoints, testDone

 

   if shouldRun(name):

@@ -148,7 +148,7 @@ macro check*(conditions: stmt): stmt {.immediate.} =
     var ast = conditions.treeRepr

     error conditions.lineinfo & ": Malformed check statement:\n" & ast

 

-template require*(conditions: stmt): stmt {.dirty.} =

+template require*(conditions: stmt): stmt {.immediate, dirty.} =

   block:

     const AbortOnError {.inject.} = true

     check conditions

diff --git a/lib/system/threads.nim b/lib/system/threads.nim
index 81e0cb00a..935f0433b 100755
--- a/lib/system/threads.nim
+++ b/lib/system/threads.nim
@@ -245,9 +245,7 @@ when not defined(useNimRtl):
 # We jump through some hops here to ensure that Nimrod thread procs can have
 # the Nimrod calling convention. This is needed because thread procs are 
 # ``stdcall`` on Windows and ``noconv`` on UNIX. Alternative would be to just
-# use ``stdcall`` since it is mapped to ``noconv`` on UNIX anyway. However, 
-# the current approach will likely result in less problems later when we have
-# GC'ed closures in Nimrod.
+# use ``stdcall`` since it is mapped to ``noconv`` on UNIX anyway.
 
 type
   TThread* {.pure, final.}[TArg] =
@@ -265,7 +263,7 @@ type
 when not defined(boehmgc) and not hasSharedHeap:
   proc deallocOsPages()
 
-template ThreadProcWrapperBody(closure: expr) =
+template ThreadProcWrapperBody(closure: expr) {.immediate.} =
   when defined(globalsSlot): ThreadVarSetValue(globalsSlot, closure)
   var t = cast[ptr TThread[TArg]](closure)
   when useStackMaskHack:
diff --git a/tests/compile/talias.nim b/tests/compile/talias.nim
index 1a93e5249..819289c2e 100644
--- a/tests/compile/talias.nim
+++ b/tests/compile/talias.nim
@@ -22,7 +22,7 @@ template `?<|` (a, b: expr) =
   compileTimeAssert isPartOf(a, b) == arMaybe
 
 type
-  TA = object
+  TA {.inheritable.} = object
   TC = object of TA
     arr: array[0..3, int]
     le, ri: ref TC
diff --git a/tests/compile/tcan_inherit_generic.nim b/tests/compile/tcan_inherit_generic.nim
index 76d9fab1f..a6f4d946b 100755
--- a/tests/compile/tcan_inherit_generic.nim
+++ b/tests/compile/tcan_inherit_generic.nim
@@ -5,7 +5,7 @@
 ## Copyright (c) 2011 FWA. All rights reserved.
 
 type
-  TGen[T] = object
+  TGen[T] = object of TObject
     x, y: T
   
   TSpef[T] = object of TGen[T]
diff --git a/tests/compile/tcan_specialise_generic.nim b/tests/compile/tcan_specialise_generic.nim
index f98a8bf95..64d5f56e3 100755
--- a/tests/compile/tcan_specialise_generic.nim
+++ b/tests/compile/tcan_specialise_generic.nim
@@ -5,7 +5,7 @@
 ## Copyright (c) 2011 FWA. All rights reserved.
 
 type
-  TGen[T] = object
+  TGen[T] = object {.inheritable.}
   TSpef = object of TGen[string]
   
 
diff --git a/tests/compile/tccgen1.nim b/tests/compile/tccgen1.nim
index b1d8835f2..137dd545d 100755
--- a/tests/compile/tccgen1.nim
+++ b/tests/compile/tccgen1.nim
@@ -7,7 +7,7 @@ type
     Features: seq[Feature] # Read-Only
 
   PNode* = ref Node
-  Node = object
+  Node = object {.inheritable.}
     attributes*: seq[PAttr]
     childNodes*: seq[PNode]
     FLocalName: string # Read-only
diff --git a/tests/compile/tdumpast.nim b/tests/compile/tdumpast.nim
index 20a041c5b..55a964327 100755
--- a/tests/compile/tdumpast.nim
+++ b/tests/compile/tdumpast.nim
@@ -8,8 +8,9 @@ template plus(a, b: expr): expr =
 macro call(e: expr): expr =
   result = newCall("foo", newStrLitNode("bar"))
   
-macro dumpAST(n: stmt): stmt =
+macro dumpAST(n: stmt): stmt {.immediate.} =
   # dump AST as a side-effect and return the inner node
+  let n = callsite()
   echo n.lispRepr
   echo n.treeRepr
 
diff --git a/tests/compile/tdumpast2.nim b/tests/compile/tdumpast2.nim
index fb31af0ec..c6eab39a9 100644
--- a/tests/compile/tdumpast2.nim
+++ b/tests/compile/tdumpast2.nim
@@ -21,8 +21,9 @@ proc dumpit(n: PNimrodNode): string {.compileTime.} =
       add(result, dumpit(n[j]))
   add(result, ")")
   
-macro dumpAST(n: stmt): stmt = 
+macro dumpAST(n: stmt): stmt {.immediate.} = 
   # dump AST as a side-effect and return the inner node
+  let n = callsite()
   echo dumpit(n)
   result = n[1]
   
diff --git a/tests/compile/teval1.nim b/tests/compile/teval1.nim
index 8172ebe28..a02f26592 100755
--- a/tests/compile/teval1.nim
+++ b/tests/compile/teval1.nim
@@ -5,7 +5,7 @@ proc testProc: string {.compileTime.} =
   result = result & ""
 
 when true:
-  macro test(n: stmt): stmt =
+  macro test(n: stmt): stmt {.immediate.} =
     result = newNimNode(nnkStmtList)
     echo "#", testProc(), "#"
   test:
diff --git a/tests/compile/thallo.nim b/tests/compile/thallo.nim
index ff90c5c0a..7244c27a1 100755
--- a/tests/compile/thallo.nim
+++ b/tests/compile/thallo.nim
@@ -15,7 +15,8 @@ proc fac[T](x: T): T =
   if x <= 1: return 1
   else: return x.`*`(fac(x-1))
 
-macro macrotest(n: expr): stmt =
+macro macrotest(n: expr): stmt {.immediate.} =
+  let n = callsite()
   expectKind(n, nnkCall)
   expectMinLen(n, 2)
   result = newNimNode(nnkStmtList, n)
@@ -23,7 +24,8 @@ macro macrotest(n: expr): stmt =
     result.add(newCall("write", n[1], n[i]))
   result.add(newCall("writeln", n[1], newStrLitNode("")))
 
-macro debug(n: expr): stmt =
+macro debug(n: expr): stmt {.immediate.} =
+  let n = callsite()
   result = newNimNode(nnkStmtList, n)
   for i in 1..n.len-1:
     result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
diff --git a/tests/compile/tmacro1.nim b/tests/compile/tmacro1.nim
index 520b64e67..3a67c2611 100755
--- a/tests/compile/tmacro1.nim
+++ b/tests/compile/tmacro1.nim
@@ -2,7 +2,7 @@ import  macros
 
 from uri import `/`
 
-macro test*(a: stmt): stmt =
+macro test*(a: stmt): stmt {.immediate.} =
   var nodes: tuple[a, b: int]  
   nodes.a = 4
   nodes[1] = 45
diff --git a/tests/compile/tmacrostmt.nim b/tests/compile/tmacrostmt.nim
index 5d1403dac..69b49f692 100755
--- a/tests/compile/tmacrostmt.nim
+++ b/tests/compile/tmacrostmt.nim
@@ -1,5 +1,5 @@
 import macros
-macro case_token(n: stmt): stmt =
+macro case_token(n: stmt): stmt {.immediate.} =
   # creates a lexical analyzer from regular expressions
   # ... (implementation is an exercise for the reader :-)
   nil
diff --git a/tests/compile/tobjcov.nim b/tests/compile/tobjcov.nim
index 40360020a..fc44edf8e 100755
--- a/tests/compile/tobjcov.nim
+++ b/tests/compile/tobjcov.nim
@@ -1,7 +1,7 @@
 # Covariance is not type safe:
 
 type
-  TA = object
+  TA = object of TObject
     a: int
   TB = object of TA
     b: array[0..5000_000, int]
diff --git a/tests/compile/tobject2.nim b/tests/compile/tobject2.nim
index 8f69a6bac..0f1869695 100755
--- a/tests/compile/tobject2.nim
+++ b/tests/compile/tobject2.nim
@@ -1,7 +1,7 @@
 # Tests the object implementation
 
 type
-  TPoint2d = object
+  TPoint2d {.inheritable.} = object
     x, y: int
 
   TPoint3d = object of TPoint2d
diff --git a/tests/compile/tobjects.nim b/tests/compile/tobjects.nim
index 40abae312..68705d944 100755
--- a/tests/compile/tobjects.nim
+++ b/tests/compile/tobjects.nim
@@ -1,5 +1,5 @@
 type

-  TBase = object

+  TBase = object of TObject

     x, y: int

 

   TSubclassKind = enum ka, kb, kc, kd, ke, kf

diff --git a/tests/compile/toop.nim b/tests/compile/toop.nim
index 5999a8073..0b42c2c22 100755
--- a/tests/compile/toop.nim
+++ b/tests/compile/toop.nim
@@ -3,7 +3,7 @@ discard """
 """
 
 type
-  TA = object
+  TA = object of TObject
     x, y: int
   
   TB = object of TA
diff --git a/tests/compile/tradix.nim b/tests/compile/tradix.nim
index 379876ea1..e5998ee12 100755
--- a/tests/compile/tradix.nim
+++ b/tests/compile/tradix.nim
@@ -9,7 +9,7 @@ const bitsPerUnit = 8*sizeof(int)
 type
   TRadixNodeKind = enum rnLinear, rnFull, rnLeafBits, rnLeafLinear
   PRadixNode = ptr TRadixNode
-  TRadixNode {.pure.} = object
+  TRadixNode {.pure, inheritable.} = object
     kind: TRadixNodeKind
   TRadixNodeLinear = object of TRadixNode
     len: int8
@@ -78,7 +78,7 @@ proc exclLeaf(r: PRadixNode, a: int) =
         return
   else: assert(false)
 
-proc in_Operator*(r: PRadixNode, a: TAddress): bool =
+proc contains*(r: PRadixNode, a: TAddress): bool =
   if r == nil: return false
   var x = searchInner(r, a shr 24 and 0xff)
   if x == nil: return false
diff --git a/tests/compile/tstrset.nim b/tests/compile/tstrset.nim
index d81ab44c9..9cdb5ed35 100755
--- a/tests/compile/tstrset.nim
+++ b/tests/compile/tstrset.nim
@@ -3,7 +3,7 @@
 type
   TRadixNodeKind = enum rnLinear, rnFull, rnLeaf
   PRadixNode = ref TRadixNode
-  TRadixNode = object
+  TRadixNode = object {.inheritable.}
     kind: TRadixNodeKind
   TRadixNodeLinear = object of TRadixNode
     len: int8
@@ -47,7 +47,7 @@ proc search(r: PRadixNode, s: string): PRadixNode =
         inc(j)
         inc(i)
 
-proc in_Operator*(r: PRadixNode, s: string): bool =
+proc contains*(r: PRadixNode, s: string): bool =
   return search(r, s) != nil
 
 proc testOrincl*(r: var PRadixNode, s: string): bool =
diff --git a/tests/compile/ttempl3.nim b/tests/compile/ttempl3.nim
index a2e95ab03..361d11f6e 100755
--- a/tests/compile/ttempl3.nim
+++ b/tests/compile/ttempl3.nim
@@ -1,7 +1,8 @@
 
 template withOpenFile(f: expr, filename: string, mode: TFileMode,
-                      actions: stmt): stmt =
+                      actions: stmt): stmt {.immediate.} =
   block:
+    # test that 'f' is implicitely 'injecting':
     var f: TFile
     if open(f, filename, mode):
       try:
@@ -15,11 +16,11 @@ withOpenFile(txt, "ttempl3.txt", fmWrite):
   writeln(txt, "line 1")
   txt.writeln("line 2")
   
-# Test zero argument template: 
-template ha: expr = myVar[0]
-  
 var
   myVar: array[0..1, int]
+
+# Test zero argument template: 
+template ha: expr = myVar[0]
   
 ha = 1  
 echo(ha)
@@ -32,7 +33,7 @@ var `hu "XYZ"` = "yay"
 
 echo prefix(XYZ)
 
-template typedef(name: expr, typ: typeDesc) {.immediate.} =
+template typedef(name: expr, typ: typeDesc) {.immediate, dirty.} =
   type
     `T name`* = typ
     `P name`* = ref `T name`
diff --git a/tests/reject/tind1.nim b/tests/reject/tind1.nim
index 6c4135d85..f3f3cacf7 100644
--- a/tests/reject/tind1.nim
+++ b/tests/reject/tind1.nim
@@ -11,7 +11,7 @@ var x = if 4 != 5:
   else:
     "no"
 
-macro mymacro(n: expr): expr = result = n[0]
+macro mymacro(n: expr): stmt {.immediate.} = nil
 
 mymacro:
   echo "test"