summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJuan M Gómez <info@jmgomez.me>2023-09-10 11:45:36 +0100
committerGitHub <noreply@github.com>2023-09-10 12:45:36 +0200
commit8032f252b2a338b01129f6331b60da937e6df8bd (patch)
tree173fe387ec8a8f89e3c26702b76dc5879034919f /tests
parentcd24195d442301b5012020fbd627686f10833c87 (diff)
downloadNim-8032f252b2a338b01129f6331b60da937e6df8bd.tar.gz
fixes #22669 constructor pragma doesnt init Nim default fields (#22670)
fixes #22669 constructor pragma doesnt init Nim default fields

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/cpp/tconstructor.nim35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/cpp/tconstructor.nim b/tests/cpp/tconstructor.nim
index b69162661..32fb5e1a2 100644
--- a/tests/cpp/tconstructor.nim
+++ b/tests/cpp/tconstructor.nim
@@ -7,6 +7,15 @@ discard """
 123
 0
 123
+___
+0
+777
+10
+123
+0
+777
+10
+123
 '''
 """
 
@@ -73,4 +82,28 @@ proc main =
     n.x = 123
     echo n.x
 
-main()
\ No newline at end of file
+main()
+#bug:
+echo "___"
+type
+  NimClassWithDefault = object
+    x: int
+    y = 777
+    case kind: bool = true
+    of true:
+      z: int = 10
+    else: discard
+
+proc makeNimClassWithDefault(): NimClassWithDefault {.constructor.} =
+  discard
+
+proc init =
+  for i in 0 .. 1:
+    var n = makeNimClassWithDefault()
+    echo n.x
+    echo n.y
+    echo n.z
+    n.x = 123
+    echo n.x
+
+init()
\ No newline at end of file