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

Can't use seq with object variant with {.requiresInit.} #21350

Open
gabbhack opened this issue Feb 10, 2023 · 0 comments
Open

Can't use seq with object variant with {.requiresInit.} #21350

gabbhack opened this issue Feb 10, 2023 · 0 comments

Comments

@gabbhack
Copy link

Description

type
  Object* {.requiresInit.} = object
    case kind: bool
    of true: discard
    else:
      foo: int

var temp: seq[Object]

Works on 1.6.10

Nim Version

Nim Compiler Version 1.9.1 [Windows: amd64]
Compiled at 2023-02-10
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 642136e
active boot switches: -d:release

Current Output

Hint: used config file 'E:\Dev\nim\Nim\config\nim.cfg' [Conf]
Hint: used config file 'E:\Dev\nim\Nim\config\config.nims' [Conf]
........................................................................
E:\Dev\nim\Nim\bin\test.nim(8, 5) template/generic instantiation of `setLen` from here
E:\Dev\nim\Nim\lib\system\seqs_v2.nim(121, 13) template/generic instantiation of `shrink` from here
E:\Dev\nim\Nim\lib\system\seqs_v2.nim(79, 13) Warning: setLen can potentially expand the sequence, but the element type 'Object' doesn't have a valid default value [UnsafeSetLen]
E:\Dev\nim\Nim\bin\test.nim(8, 5) template/generic instantiation of `setLen` from here
E:\Dev\nim\Nim\lib\system\seqs_v2.nim(130, 31) Warning: The 'Object' type doesn't have a valid default value [UnsafeDefault]
E:\Dev\nim\Nim\bin\test.nim(8, 5) template/generic instantiation of `setLen` from here
E:\Dev\nim\Nim\lib\system\seqs_v2.nim(130, 32) Error: The Object type requires the following fields to be initialized: foo.

Expected Output

No response

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
Development

No branches or pull requests

1 participant