summary refs log tree commit diff stats
path: root/tests/objects
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-09-26 12:28:40 +0800
committerGitHub <noreply@github.com>2024-09-26 06:28:40 +0200
commit6d6489a9ab2f83f17f5fdebe3372e86a610d7a3c (patch)
tree0e0eed8bf08a76dd9c1be5a01649a24734e47a8c /tests/objects
parent3b85c1a2e9b913a11fc7cd202b7e0a617d782cf4 (diff)
downloadNim-6d6489a9ab2f83f17f5fdebe3372e86a610d7a3c.tar.gz
fixes requiresInit for var statements without initialization (#24177)
ref https://forum.nim-lang.org/t/12530
Diffstat (limited to 'tests/objects')
-rw-r--r--tests/objects/trequireinit.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/objects/trequireinit.nim b/tests/objects/trequireinit.nim
new file mode 100644
index 000000000..202667b02
--- /dev/null
+++ b/tests/objects/trequireinit.nim
@@ -0,0 +1,10 @@
+discard """
+  errormsg: "The MPlayerObj type doesn't have a default value. The following fields must be initialized: foo."
+"""
+
+type
+  MPlayerObj* {.requiresInit.} = object
+    foo: range[5..10] = 5
+
+var a: MPlayerObj
+echo a.foo
\ No newline at end of file