Handle record types with when statements

This commit is contained in:
Zahary Karadjov 2020-12-22 20:24:43 +02:00
parent 474bdbf49c
commit dfd6e349a6
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 6 additions and 5 deletions

View File

@ -131,14 +131,15 @@ macro enumAllSerializedFieldsImpl(T: type, body: untyped): untyped =
result.add quote do:
block:
`fieldNameDefs`
when compiles(type(`field`)):
`fieldNameDefs`
type FieldType {.inject, used.} = type(`field`)
type FieldType {.inject, used.} = type(`field`)
template fieldCaseDiscriminator: auto {.used.} = `discriminator`
template fieldCaseBranches: auto {.used.} = `branches`
template fieldCaseDiscriminator: auto {.used.} = `discriminator`
template fieldCaseBranches: auto {.used.} = `branches`
`body`
`body`
i += 1