summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-02-03 17:35:58 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-02-03 17:35:58 +0100
commit26fb6cb07357b0565f2d53c387c50f9727b9f579 (patch)
tree0983eaed14ec7a4328d8535c67ffaea36d10d9c1 /tests
parent4ac6a2603167a3199dfce60f07dba3a5188ea7a8 (diff)
downloadNim-26fb6cb07357b0565f2d53c387c50f9727b9f579.tar.gz
fixes #5327
Diffstat (limited to 'tests')
-rw-r--r--tests/vm/tableinstatic.nim38
-rw-r--r--tests/vm/tcompiletimetable.nim10
2 files changed, 43 insertions, 5 deletions
diff --git a/tests/vm/tableinstatic.nim b/tests/vm/tableinstatic.nim
new file mode 100644
index 000000000..54e7c11f0
--- /dev/null
+++ b/tests/vm/tableinstatic.nim
@@ -0,0 +1,38 @@
+discard """
+  nimout: '''0
+0
+0
+{hallo: 123, welt: 456}'''
+"""
+
+import tables
+
+# bug #5327
+
+type
+  MyType* = object
+    counter: int
+
+proc foo(t: var MyType) =
+  echo t.counter
+
+proc bar(t: MyType) =
+  echo t.counter
+
+static:
+  var myValue: MyType
+  myValue.foo # works nicely
+
+  var refValue: ref MyType
+  refValue.new
+
+  refValue[].foo # fails to compile
+  refValue[].bar # works again nicely
+
+static:
+  var otherTable = newTable[string, string]()
+
+  otherTable["hallo"] = "123"
+  otherTable["welt"]  = "456"
+
+  echo otherTable
diff --git a/tests/vm/tcompiletimetable.nim b/tests/vm/tcompiletimetable.nim
index df6ead56f..e78c06536 100644
--- a/tests/vm/tcompiletimetable.nim
+++ b/tests/vm/tcompiletimetable.nim
@@ -1,5 +1,5 @@
 discard """
-  msg: '''2
+  nimout: '''2
 3
 4:2
 Got Hi
@@ -13,7 +13,7 @@ import macros, tables, strtabs
 var ZOOT{.compileTime.} = initTable[int, int](2)
 var iii {.compiletime.} = 1
 
-macro zoo:stmt=
+macro zoo: untyped =
   ZOOT[iii] = iii*2
   inc iii
   echo iii
@@ -22,7 +22,7 @@ zoo
 zoo
 
 
-macro tupleUnpack: stmt =
+macro tupleUnpack: untyped =
   var (y,z) = (4, 2)
   echo y, ":", z
 
@@ -32,14 +32,14 @@ tupleUnpack
 
 var x {.compileTime.}: StringTableRef
 
-macro addStuff(stuff, body: expr): stmt {.immediate.} =
+macro addStuff(stuff, body: untyped): untyped =
   result = newNimNode(nnkStmtList)
 
   if x.isNil:
     x = newStringTable(modeStyleInsensitive)
   x[$stuff] = ""
 
-macro dump(): stmt =
+macro dump(): untyped =
   result = newNimNode(nnkStmtList)
   for y in x.keys: echo "Got ", y