fixes assertion defect when encoding empty object type definition

This commit is contained in:
demotomohiro
2025-10-29 22:50:06 +09:00
parent 10885d4dce
commit 6a74316c0e
2 changed files with 5 additions and 1 deletions

View File

@@ -99,6 +99,7 @@ proc toNifDef(c: var EncodeContext; typ: PType) =
c.dest.buildTree sonsTag:
for ch in typ.kids:
c.toNif ch
c.toNif typ.n
c.toNif typ.owner
c.toNif typ.sym
@@ -188,7 +189,7 @@ proc toNif(c: var EncodeContext; n: PNode) =
c.withNode n:
discard
else:
assert n.kind in {nkArgList, nkBracket} or n.len > 0, $n.kind
assert n.kind in {nkArgList, nkBracket, nkRecList} or n.len > 0, $n.kind
c.withNode(n):
for i in 0 ..< n.len:
c.toNif n[i]

View File

@@ -21,6 +21,8 @@ type
TestPtrObj = ptr object
x: int
TestEmptyObj = object
var x: TestInt
var testEnum: TestEnum
var testEnum1 = X
@@ -34,3 +36,4 @@ var testPtrInt: TestPtrInt = nil
var testPtrInt2: ptr int = nil
var testRefObj: TestRefObj = nil
var testPtrObj: TestPtrObj = nil
var testEmptyObj: TestEmptyObj