Hi folks, Im a newcomer here and today is the second day of using Nim. Everything is great so far, but i encounter something weird when using pragma {.requiresInit.}. Here's the code.
type
EntityId = distinct int
Entity = object
id {.requiresInit.} : EntityId
name: string
transformId = ComponentId(-1)
rectangleDataId = ComponentId(-1)
var
entities: seq[Entity]
proc findEntityById(id: EntityId): Entity =
for e in entities:
if e.id == id:
return e
The loop generate this error message, and if i remove the {.reqiuresInit.} pragma, the code compiled.
Error: The Entity type requires the following fields to be initialized: id.
im looking for an explanation why is this happen and solution to work around this without removing the pragma.
Thank you in advance !