diff --git a/serialization/object_serialization.nim b/serialization/object_serialization.nim index 1219a87..2e6ebe7 100644 --- a/serialization/object_serialization.nim +++ b/serialization/object_serialization.nim @@ -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