summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/generics/tsubtypeconstraint.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/generics/tsubtypeconstraint.nim b/tests/generics/tsubtypeconstraint.nim
new file mode 100644
index 000000000..2f0954522
--- /dev/null
+++ b/tests/generics/tsubtypeconstraint.nim
@@ -0,0 +1,13 @@
+
+# bug #1684
+type
+  BaseType {.inheritable pure.} = object
+    idx: int
+
+  DerivedType* {.final pure.} = object of BaseType
+
+proc index*[Toohoo: BaseType](h: Toohoo): int {.inline.} = h.idx
+proc newDerived(idx: int): DerivedType {.inline.} = DerivedType(idx: idx)
+
+let d = newDerived(2)
+assert(d.index == 2)