Work around Nim bug that erases type `{.pragma.}` when making alias (#71)
Replaces `type` with inlined `template` because assigning to a new type drops pragma annotations in some situations.
This commit is contained in:
parent
afae13adac
commit
005ee90cb6
|
@ -104,7 +104,6 @@ macro enumAllSerializedFieldsImpl(T: type, body: untyped): untyped =
|
|||
continue
|
||||
|
||||
let
|
||||
fieldType = field.typ
|
||||
fieldIdent = field.name
|
||||
realFieldName = newLit($fieldIdent.skipPragma)
|
||||
serializedFieldName = field.readPragma("serializedFieldName")
|
||||
|
@ -137,7 +136,9 @@ macro enumAllSerializedFieldsImpl(T: type, body: untyped): untyped =
|
|||
block:
|
||||
`fieldNameDefs`
|
||||
|
||||
type FieldType {.inject, used.} = type(`field`)
|
||||
# `FieldType` should be `type`:
|
||||
# https://github.com/nim-lang/Nim/issues/23564
|
||||
template FieldType: untyped {.inject, used.} = typeof(`field`)
|
||||
|
||||
template fieldCaseDiscriminator: auto {.used.} = `discriminator`
|
||||
template fieldCaseBranches: auto {.used.} = `branches`
|
||||
|
|
Loading…
Reference in New Issue