summary refs log tree commit diff stats
path: root/tests/generics/tgenerics_and_inheritance.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generics/tgenerics_and_inheritance.nim')
-rw-r--r--tests/generics/tgenerics_and_inheritance.nim36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/generics/tgenerics_and_inheritance.nim b/tests/generics/tgenerics_and_inheritance.nim
new file mode 100644
index 000000000..ea776b517
--- /dev/null
+++ b/tests/generics/tgenerics_and_inheritance.nim
@@ -0,0 +1,36 @@
+
+# bug #7854
+
+type
+  Stream* = ref StreamObj
+  StreamObj* = object of RootObj
+
+  InhStream* = ref InhStreamObj
+  InhStreamObj* = object of Stream
+    f: string
+
+proc newInhStream*(f: string): InhStream =
+  new(result)
+  result.f = f
+
+var val: int
+let str = newInhStream("input_file.json")
+
+block:
+  # works:
+  proc load[T](data: var T, s: Stream) =
+    discard
+  load(val, str)
+
+block:
+  # works
+  proc load[T](s: Stream, data: T) =
+    discard
+  load(str, val)
+
+block:
+  # broken
+  proc load[T](s: Stream, data: var T) =
+    discard
+  load(str, val)
+