summary refs log tree commit diff stats
path: root/tests/cpp
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/cpp
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/cpp')
-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
'n196' href='#n196'>196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252