summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-03-24 00:58:28 +0100
committerAraq <rumpf_a@web.de>2011-03-24 00:58:28 +0100
commit62eb5b124e33966aaf6cc2d012d0c3d6bdd36d0c (patch)
treebf7b62899d8f84f495729ea2c7596f1d1bb2ac04
parent5b789f2da8e57ea2adf0c088f5e41fd7a71fe89b (diff)
downloadNim-62eb5b124e33966aaf6cc2d012d0c3d6bdd36d0c.tar.gz
fixes #21
-rwxr-xr-xlib/pure/gentabs.nim15
-rwxr-xr-xrod/ast.nim2
-rwxr-xr-xtests/tester.nim1
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/pure/gentabs.nim b/lib/pure/gentabs.nim
index c57a77aed..1d000ba8c 100755
--- a/lib/pure/gentabs.nim
+++ b/lib/pure/gentabs.nim
@@ -104,12 +104,10 @@ proc hasKey*[T](tbl: PGenTable[T], key: string): bool =
 
 proc `[]`*[T](tbl: PGenTable[T], key: string): T =
   ## retrieves the value at ``tbl[key]``. If `key` is not in `tbl`,
-  ## "" is returned and no exception is raised. One can check
+  ## default(T) is returned and no exception is raised. One can check
   ## with ``hasKey`` whether the key exists.
-  var index: int
-  index = RawGet(tbl, key)
+  var index = RawGet(tbl, key)
   if index >= 0: result = tbl.data[index].val
-  #else: result = ""   ### Not sure what to do here
 
 proc `[]=`*[T](tbl: PGenTable[T], key: string, val: T) =
   ## puts a (key, value)-pair into `tbl`.
@@ -141,8 +139,6 @@ when isMainModule:
   assert(not x.hasKey("NOPE"))    # ...but key "NOPE" is not in the table.
   for k,v in pairs(x):            # make sure the 'pairs' iterator works
     assert(x[k]==v)
-  echo()
-  
   
   #
   # Verify a table of user-defined types
@@ -154,15 +150,18 @@ when isMainModule:
                                                     # value is TMyType tuple
   
   #var junk: TMyType = ("OK", "Here")
+  
+  #echo junk.first, " ", junk.second
+  
   y["Hello"] = ("Hello", "World")
   y["Goodbye"] = ("Goodbye", "Everyone")
   #y["Hello"] = TMyType( ("Hello", "World") )
   #y["Goodbye"] = TMyType( ("Goodbye", "Everyone") )
 
+  assert( not isNil(y["Hello"].first) )
   assert( y["Hello"].first == "Hello" )
   assert( y["Hello"].second == "World" )
-  
-  
+    
   #
   # Verify table of tables
   #
diff --git a/rod/ast.nim b/rod/ast.nim
index c7c0fa7d0..91eb37506 100755
--- a/rod/ast.nim
+++ b/rod/ast.nim
@@ -877,7 +877,7 @@ proc newSons(father: PType, length: int) =
 proc addSon(father, son: PType) = 
   if isNil(father.sons): father.sons = @[]
   add(father.sons, son)
-  assert((father.kind != tyGenericInvokation) or (son.kind != tyGenericInst))
+  #assert((father.kind != tyGenericInvokation) or (son.kind != tyGenericInst))
 
 proc sonsLen(n: PNode): int = 
   if isNil(n.sons): result = 0
diff --git a/tests/tester.nim b/tests/tester.nim
index 93fc3f433..a309de12d 100755
--- a/tests/tester.nim
+++ b/tests/tester.nim
@@ -48,6 +48,7 @@ proc extractSpec(filename: string): string =
     result = x.copy(a+3, b-1).replace("'''", tripleQuote)
   else:
     echo "warning: file does not contain spec: " & filename
+    result = ""
 
 template parseSpecAux(fillResult: stmt) = 
   var ss = newStringStream(extractSpec(filename))