summary refs log tree commit diff stats
path: root/tests/objects
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-07-25 18:08:32 +0800
committerGitHub <noreply@github.com>2023-07-25 12:08:32 +0200
commit1c2ccfad08191e936fadd52450b53dfea105a34d (patch)
treed848422b5cd391db4efb14bf2a5b7db2307266df /tests/objects
parentdce714b2598c41e36113a4339fb9fb14655bc090 (diff)
downloadNim-1c2ccfad08191e936fadd52450b53dfea105a34d.tar.gz
fixes #22301; fixes #22324; rejects branch initialization with a runtime discriminator with defaults (#22303)
* fixes #22301; rejects branch initialization with a runtime discriminator with defaults

* undefault nimPreviewRangeDefault

* fixes tests

* use oldCheckDefault
Diffstat (limited to 'tests/objects')
-rw-r--r--tests/objects/t22301.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/objects/t22301.nim b/tests/objects/t22301.nim
new file mode 100644
index 000000000..8746bf584
--- /dev/null
+++ b/tests/objects/t22301.nim
@@ -0,0 +1,17 @@
+discard """
+  errormsg: "branch initialization with a runtime discriminator is not supported for a branch whose fields have default values."
+"""
+
+# bug #22301
+type
+  Enum = enum A, B
+  Object = object
+    case a: Enum
+    of A:
+      integer: int = 200
+    of B:
+      time: string
+
+let x = A
+let s = Object(a: x)
+echo s
\ No newline at end of file