summary refs log tree commit diff stats
path: root/tests/assign/tvariantasgn.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/assign/tvariantasgn.nim')
-rw-r--r--tests/assign/tvariantasgn.nim39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/assign/tvariantasgn.nim b/tests/assign/tvariantasgn.nim
new file mode 100644
index 000000000..4c3c38ca5
--- /dev/null
+++ b/tests/assign/tvariantasgn.nim
@@ -0,0 +1,39 @@
+discard """
+  output: "came here"
+"""
+
+#BUG
+type
+  TAnyKind = enum
+    nkInt,
+    nkFloat,
+    nkString
+  TAny = object
+    case kind: TAnyKind
+    of nkInt: intVal: int
+    of nkFloat: floatVal: float
+    of nkString: strVal: string
+
+var s: TAny
+s = TAny(kind: nkString, strVal: "test")
+
+var nr: TAny
+s = TAny(kind: nkInt, intVal: 78)
+
+
+# s = nr # works
+nr = s # fails!
+echo "came here"
+
+block: # bug #12464
+  type
+    Foo = object
+      case isFunc: bool
+      of false: nil
+      of true:
+        fun: proc(): int
+
+  const i = Foo(isFunc: false)
+
+  let j = i
+  doAssert not j.isFunc