summary refs log tree commit diff stats
path: root/tests/compile
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-01-07 20:03:41 +0100
committerAraq <rumpf_a@web.de>2012-01-07 20:03:41 +0100
commit7405278138f4e76d5e6278b3ed25f953ba9260e1 (patch)
tree7c634a657e72eb4a2aaf1e1a472531daecd6ac99 /tests/compile
parent0e22a51095d189080ef8af445376fb7ccc061c85 (diff)
downloadNim-7405278138f4e76d5e6278b3ed25f953ba9260e1.tar.gz
bugfix: type alias to generic; generic type not stripped away from for loop variable
Diffstat (limited to 'tests/compile')
-rw-r--r--tests/compile/tgeneric.nim11
-rw-r--r--tests/compile/tgeneric2.nim11
-rw-r--r--tests/compile/tgenericprop.nim12
3 files changed, 34 insertions, 0 deletions
diff --git a/tests/compile/tgeneric.nim b/tests/compile/tgeneric.nim
new file mode 100644
index 000000000..8bda15c42
--- /dev/null
+++ b/tests/compile/tgeneric.nim
@@ -0,0 +1,11 @@
+import tables
+
+type
+  TX = TTable[string, int]
+
+proc foo(models: seq[TTable[string, float]]): seq[float] =
+  result = @[]
+  for model in models.items:
+    result.add model["foobar"]
+
+
diff --git a/tests/compile/tgeneric2.nim b/tests/compile/tgeneric2.nim
new file mode 100644
index 000000000..b9b8e5a62
--- /dev/null
+++ b/tests/compile/tgeneric2.nim
@@ -0,0 +1,11 @@
+import tables
+
+type
+  TX = TTable[string, int]
+
+proc foo(models: seq[TX]): seq[int] =
+  result = @[]
+  for model in models.items:
+    result.add model["foobar"]
+
+
diff --git a/tests/compile/tgenericprop.nim b/tests/compile/tgenericprop.nim
new file mode 100644
index 000000000..211fddecf
--- /dev/null
+++ b/tests/compile/tgenericprop.nim
@@ -0,0 +1,12 @@
+
+type
+  TProperty[T] = object of TObject
+    getProc: proc(property: TProperty[T]): T
+    setProc: proc(property: TProperty[T], value: T)
+    value: T
+
+proc newProperty[T](value: TObject): TProperty[T] =
+  result.getProc = proc (property: TProperty[T]) =
+    return property.value
+
+