summary refs log tree commit diff stats
path: root/tests/notnil
diff options
context:
space:
mode:
Diffstat (limited to 'tests/notnil')
-rw-r--r--tests/notnil/tnotnil_in_objconstr.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/notnil/tnotnil_in_objconstr.nim b/tests/notnil/tnotnil_in_objconstr.nim
new file mode 100644
index 000000000..2110bda8f
--- /dev/null
+++ b/tests/notnil/tnotnil_in_objconstr.nim
@@ -0,0 +1,14 @@
+discard """
+  errormsg: "field not initialized: bar"
+  line: "13"
+"""
+
+# bug #2355
+type
+  Foo = object
+    foo: string not nil
+    bar: string not nil
+
+# Create instance without initializaing the `bar` field
+var f = Foo(foo: "foo")
+echo f.bar.isNil # true