Skip to content

Commit 95ee8de

Browse files
committed
fixes bug
1 parent c16c667 commit 95ee8de

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

compiler/icnif/nifdecoder.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ proc fromNifTypeSection(c: var DecodeContext; n: var Cursor): PNode =
150150
result[0] = sym
151151
else:
152152
var postfix = newNodeI(nkPostfix, unknownLineInfo, 2)
153-
postfix.add newIdentNode(c.graph.cache.getIdent("*"), unknownLineInfo)
154-
postfix.add sym
153+
postfix[0] = newIdentNode(c.graph.cache.getIdent("*"), unknownLineInfo)
154+
postfix[1] = sym
155155
result[0] = postfix
156156
inc n
157157

tests/icnif/tencode_node2node.nim

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ proc eql(x, y: PNode; c: var EqlContext): bool =
140140
result = true
141141
elif x == nil or y == nil:
142142
result = false
143-
elif x.kind == y.kind and x.safeLen == y.safeLen and x.flags == y.flags:
143+
elif x.kind != y.kind:
144+
echo "node kind mismatch: ", x.kind, "/", y.kind
145+
result = false
146+
elif x.flags != y.flags:
147+
echo "node flag mismatch: ", x.flags, "/", y.flags
148+
result = false
149+
elif x.safeLen == y.safeLen:
144150
if c.nodeStack.len != 0:
145151
for i in countDown(c.nodeStack.len - 1, 0):
146152
if x == c.nodeStack[i]:
@@ -160,16 +166,23 @@ proc eql(x, y: PNode; c: var EqlContext): bool =
160166
result = sameValue(x, y)
161167
of nkIdentDefs:
162168
assert x.len == 3 and y.len == 3
163-
if eql(x[0], y[0], c) and eql(x[2], y[2], c):
164-
result = y[1].kind == nkEmpty and y[0].sym.typ != nil
169+
if eql(x[0], y[0], c) and eql(x[2], y[2], c) and y[1].kind == nkEmpty and y[0].sym.typ != nil:
170+
result = true
165171
else:
172+
echo "nkIdentDefs mismatch"
166173
result = false
167174
of nkTypeDef:
168175
assert x.len == 3 and y.len == 3
169176
if eql(x[0], y[0], c) and eql(x[1], y[1], c):
170-
result = y[2].kind == nkEmpty and y[0].sym.typ != nil
177+
let sym = if y[0].kind == nkPostfix:
178+
y[0][1].sym
179+
else:
180+
y[0].sym
181+
result = y[2].kind == nkEmpty and sym.typ != nil
171182
else:
172183
result = false
184+
if not result:
185+
echo "nkTypeDef mismatch"
173186
else:
174187
result = true
175188
for i in 0 ..< x.safeLen:
@@ -178,6 +191,9 @@ proc eql(x, y: PNode; c: var EqlContext): bool =
178191
break
179192
discard c.nodeStack.pop
180193
else:
194+
echo "node length mismatch"
195+
debug(x)
196+
debug(y)
181197
result = false
182198

183199
proc testNifEncDec(graph: ModuleGraph; src: string) =

tests/icnif/testcode/modtesttypesections.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ type
99
x*: int
1010
y: int
1111

12+
TestObject2* = object
13+
x: TestObject
14+
1215
var x: TestInt
1316
var testEnum: TestEnum
1417
var testEnum1 = X
1518
var testDistinct: TestDistinct
1619
var testObject: TestObject
20+
var testObject2*: TestObject2

0 commit comments

Comments
 (0)