From 09b131c9191b22848cf2dd69d96d4da685c6d3bb Mon Sep 17 00:00:00 2001 From: jangko Date: Mon, 5 Jun 2023 11:43:19 +0700 Subject: [PATCH] another attempt to reduce compiler warnings --- serialization.nim | 7 +++---- serialization/object_serialization.nim | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) 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,