Skip to content

Commit 7733ac8

Browse files
committed
fixes assertion defect when encoding empty object type definition
1 parent 1fe23a1 commit 7733ac8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/icnif/nifencoder.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ proc toNifDef(c: var EncodeContext; typ: PType) =
9999
c.dest.buildTree sonsTag:
100100
for ch in typ.kids:
101101
c.toNif ch
102+
102103
c.toNif typ.n
103104
c.toNif typ.owner
104105
c.toNif typ.sym
@@ -188,7 +189,7 @@ proc toNif(c: var EncodeContext; n: PNode) =
188189
c.withNode n:
189190
discard
190191
else:
191-
assert n.kind in {nkArgList, nkBracket} or n.len > 0, $n.kind
192+
assert n.kind in {nkArgList, nkBracket, nkRecList} or n.len > 0, $n.kind
192193
c.withNode(n):
193194
for i in 0 ..< n.len:
194195
c.toNif n[i]

tests/icnif/testcode/modtesttypesections.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type
2121
TestPtrObj = ptr object
2222
x: int
2323

24+
TestEmptyObj = object
25+
2426
var x: TestInt
2527
var testEnum: TestEnum
2628
var testEnum1 = X
@@ -34,3 +36,4 @@ var testPtrInt: TestPtrInt = nil
3436
var testPtrInt2: ptr int = nil
3537
var testRefObj: TestRefObj = nil
3638
var testPtrObj: TestPtrObj = nil
39+
var testEmptyObj: TestEmptyObj

0 commit comments

Comments
 (0)