summary refs log tree commit diff stats
path: root/tests/destructor/tcast.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/destructor/tcast.nim')
-rw-r--r--tests/destructor/tcast.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/destructor/tcast.nim b/tests/destructor/tcast.nim
new file mode 100644
index 000000000..7d5a1954c
--- /dev/null
+++ b/tests/destructor/tcast.nim
@@ -0,0 +1,18 @@
+discard """
+  cmd: '''nim c --newruntime $file'''
+"""
+
+# Make sure we don't walk cast[T] type section while injecting sinks/destructors
+block:
+  type
+    XY[T] = object
+      discard
+
+  proc `=`[T](x: var XY[T]; v: XY[T]) {.error.}
+  proc `=sink`[T](x: var XY[T]; v: XY[T]) {.error.}
+
+  proc main[T]() =
+    var m = cast[ptr XY[T]](alloc0(sizeof(XY[T])))
+    doAssert(m != nil)
+
+  main[int]()