summary refs log tree commit diff stats
path: root/tests/objects/tobj_asgn_dont_slice.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/objects/tobj_asgn_dont_slice.nim')
-rw-r--r--tests/objects/tobj_asgn_dont_slice.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/objects/tobj_asgn_dont_slice.nim b/tests/objects/tobj_asgn_dont_slice.nim
new file mode 100644
index 000000000..ce67c4490
--- /dev/null
+++ b/tests/objects/tobj_asgn_dont_slice.nim
@@ -0,0 +1,25 @@
+discard """
+  matrix: "--mm:refc"
+  outputsub: '''ObjectAssignmentDefect'''
+  exitcode: "1"
+"""
+
+# bug #7637
+type
+  Fruit = object of RootObj
+    name*: string
+  Apple = object of Fruit
+  Pear = object of Fruit
+
+method eat(f: Fruit) {.base.} =
+  raise newException(Exception, "PURE VIRTUAL CALL")
+
+method eat(f: Apple) =
+  echo "fruity"
+
+method eat(f: Pear) =
+  echo "juicy"
+
+let basket = [Apple(name:"a"), Pear(name:"b")]
+
+eat(basket[0])