summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2012-04-11 01:14:56 +0300
committerZahary Karadjov <zahary@gmail.com>2012-04-11 01:52:12 +0300
commit238202ccbc418dece73086f0d009b2b6fe3850ca (patch)
treeaaa6c9a0cc6c6e3fcb9d42c6cb1eba94c6ca1544
parentc1ad05c4c582a6b51c47095b7ab946d5df10d72c (diff)
downloadNim-238202ccbc418dece73086f0d009b2b6fe3850ca.tar.gz
re-enable rodfiles tests; fixes #91
-rwxr-xr-xcompiler/ccgstmts.nim3
-rwxr-xr-xcompiler/semtypes.nim7
-rwxr-xr-xtests/reject/ttypenoval.nim2
-rw-r--r--tests/rodfiles/bmethods.nim1
-rw-r--r--tests/rodfiles/bmethods2.nim1
-rw-r--r--tests/run/tenumitems.nim14
-rw-r--r--tests/specials.nim3
7 files changed, 25 insertions, 6 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim
index e018a3ac9..5ad9d8b44 100755
--- a/compiler/ccgstmts.nim
+++ b/compiler/ccgstmts.nim
@@ -53,7 +53,8 @@ proc genSingleVar(p: BProc, a: PNode) =
   var targetProc = p
   var immediateAsgn = a.sons[2].kind != nkEmpty
   if sfGlobal in v.flags:
-    targetProc = p.module.preInitProc
+    if v.owner.kind != skModule:
+      targetProc = p.module.preInitProc
     assignGlobalVar(targetProc, v)
     genObjectInit(targetProc, cpsInit, v.typ, v.loc, true)
   else:
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index be5bd95d9..5626da6f9 100755
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -181,7 +181,12 @@ proc semTypeIdent(c: PContext, n: PNode): PSym =
     if result != nil:
       markUsed(n, result)
       if result.kind == skParam and result.typ.kind == tyTypeDesc:
-        return result.typ.sons[0].sym
+        # This is a typedesc param. is it already bound?
+        # it's not bound when it's also used as return type for example
+        if result.typ.sonsLen > 0:
+          return result.typ.sons[0].sym
+        else:
+          return result.typ.sym
       if result.kind != skType: GlobalError(n.info, errTypeExpected)
       if result.typ.kind != tyGenericParam:
         # XXX get rid of this hack!
diff --git a/tests/reject/ttypenoval.nim b/tests/reject/ttypenoval.nim
index 9944e52a1..6362407ef 100755
--- a/tests/reject/ttypenoval.nim
+++ b/tests/reject/ttypenoval.nim
@@ -1,7 +1,7 @@
 discard """
   file: "ttypenoval.nim"
   line: 38
-  errormsg: "a type has no value"
+  errormsg: "type mismatch: got (typedesc{int}) but expected 'int'"
 """
 
 # A min-heap.
diff --git a/tests/rodfiles/bmethods.nim b/tests/rodfiles/bmethods.nim
index 39aa5368c..995942ad6 100644
--- a/tests/rodfiles/bmethods.nim
+++ b/tests/rodfiles/bmethods.nim
@@ -1,5 +1,4 @@
 discard """
-  disabled: true
   output: '''derived class
 base class
 '''
diff --git a/tests/rodfiles/bmethods2.nim b/tests/rodfiles/bmethods2.nim
index 0d1795a27..7ffb27f15 100644
--- a/tests/rodfiles/bmethods2.nim
+++ b/tests/rodfiles/bmethods2.nim
@@ -1,5 +1,4 @@
 discard """
-  disabled: true
   output: '''derived class 2  
 base class
 '''
diff --git a/tests/run/tenumitems.nim b/tests/run/tenumitems.nim
new file mode 100644
index 000000000..516839fb3
--- /dev/null
+++ b/tests/run/tenumitems.nim
@@ -0,0 +1,14 @@
+discard """
+  output: "A\nB\nC"
+"""
+
+type TAlphabet = enum
+  A, B, C
+
+iterator items(E: typedesc): E =
+  for v in low(E)..high(E):
+    yield v
+
+for c in TAlphabet:
+  echo($c)
+
diff --git a/tests/specials.nim b/tests/specials.nim
index 05eda6061..3dc083f2e 100644
--- a/tests/specials.nim
+++ b/tests/specials.nim
@@ -22,7 +22,8 @@ proc delNimCache() =
   except EOS:
     echo "[Warning] could not delete: ", dir
     
-proc plusCache(options: string): string = return options & " --symbolFiles:on"
+proc plusCache(options: string): string = return options &
+  " --symbolFiles:on --nimcache:./nimcache"
 
 proc runRodFiles(r: var TResults, options: string) =
   template test(filename: expr): stmt =