Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default value in object variants does not work when embedded in another object #23770

Closed
jxy opened this issue Jun 28, 2024 · 0 comments · Fixed by #24466
Closed

default value in object variants does not work when embedded in another object #23770

jxy opened this issue Jun 28, 2024 · 0 comments · Fixed by #24466
Assignees

Comments

@jxy
Copy link
Contributor

jxy commented Jun 28, 2024

Description

If a field in an object has an object variant type, the default value from that object variant type is ignored.

type
  Enum = enum A, B
  Object = object
    case a: Enum
    of A:
      integer: int = 200
    of B:
      time: string
  Simple = object
    v = -1
  Another = object
    o = Object(a: A)
    v: Simple

echo Object(a: A)
echo Another()

Nim Version

Nim Compiler Version 2.1.1 [MacOSX: arm64]
Compiled at 2024-06-21
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 2bef087
active boot switches: -d:release

Current Output

(a: A, integer: 200)
(o: (a: A, integer: 0), v: (v: -1))

Expected Output

(a: A, integer: 200)
(o: (a: A, integer: 200), v: (v: -1))

Possible Solution

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants