preserves_schema_nim: always mark embedded fields

This commit is contained in:
Emery Hemingway 2024-01-01 14:11:50 +02:00
parent 25d42f9498
commit b67e6f089b
2 changed files with 2 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "20231230"
version = "20240101"
author = "Emery Hemingway"
description = "data model and serialization format"
license = "Unlicense"

View File

@ -126,11 +126,6 @@ proc deref(loc: Location; r: Ref): (Location, Definition) =
except KeyError:
raise newException(KeyError, "reference not found in bundle: " & $r)
proc hasEmbeddedType(scm: Schema): bool =
case scm.field0.embeddedType.orKind
of EmbeddedtypenameKind.false: false
of EmbeddedtypenameKind.Ref: true
proc hash(r: Ref): Hash = r.toPreserves.hash
type RefSet = HashSet[Ref]
@ -611,7 +606,7 @@ proc addField(recList: PNode; loc: Location; known: var TypeTable; sp: SimplePat
ident"preservesLiteral",
toStrLit(loc, sp))))
recList.add identDef(scm, id, TypeSpec(node: ident"tuple[]"))
elif sp.orKind == SimplePatternKind.embedded and not scm.hasEmbeddedType:
elif sp.orKind == SimplePatternKind.embedded:
let id = nkPragmaExpr.newTree(
id, nkPragma.newTree(ident"preservesEmbedded"))
recList.add identDef(scm, id, nimTypeOf(loc, known, "", sp))