diff --git a/serialization.nim b/serialization.nim index 911e6bc..dc7d901 100644 --- a/serialization.nim +++ b/serialization.nim @@ -23,13 +23,12 @@ template encode*(Format: type, value: auto, params: varargs[untyped]): auto = raise (ref Defect)() # a memoryOutput cannot have an IOError # TODO Nim cannot make sense of this initialization by var param? -{.push warning[ProveInit]: off.} proc readValue*(reader: var auto, T: type): T = + {.warning[ProveInit]: off.} mixin readValue - when (NimMajor, NimMinor) > (1, 6): - result = default(T) + result = default(T) reader.readValue(result) -{.pop.} + {.warning[ProveInit]: on.} template decode*(Format: distinct type, input: string, diff --git a/serialization/object_serialization.nim b/serialization/object_serialization.nim index f03a226..0ba788c 100644 --- a/serialization/object_serialization.nim +++ b/serialization/object_serialization.nim @@ -197,7 +197,10 @@ template readFieldIMPL[Reader](field: type FieldTag, # additional notes: putting the FieldType coercion in # `makeFieldReadersTable` will cause problems when orc enabled # hence, move it here - FieldType reader.readValue(FieldType) + when distinctBase(FieldType) isnot FieldType: + FieldType reader.readValue(FieldType) + else: + reader.readValue(FieldType) template writeFieldIMPL*[Writer](writer: var Writer, fieldTag: type FieldTag,