mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #22669 constructor pragma doesnt init Nim default fields --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user