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>
This commit is contained in:
Juan M Gómez
2023-09-10 11:45:36 +01:00
committed by GitHub
parent cd24195d44
commit 8032f252b2
4 changed files with 66 additions and 20 deletions

View File

@@ -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()
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()