summary refs log tree commit diff stats
path: root/tests/objvariant/tadrdisc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/objvariant/tadrdisc.nim')
-rw-r--r--tests/objvariant/tadrdisc.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/objvariant/tadrdisc.nim b/tests/objvariant/tadrdisc.nim
new file mode 100644
index 000000000..5e4e39a44
--- /dev/null
+++ b/tests/objvariant/tadrdisc.nim
@@ -0,0 +1,20 @@
+discard """
+  errormsg: "type mismatch: got <TKind>"
+  file: "tadrdisc.nim"
+  line: 20
+"""
+# Test that the address of a discriminants cannot be taken
+
+type
+  TKind = enum ka, kb, kc
+  TA = object
+    case k: TKind
+    of ka: x, y: int
+    of kb: a, b: string
+    of kc: c, d: float
+
+proc setKind(k: var TKind) =
+  k = kc
+
+var a: TA
+setKind(a.k)