Skip to content

Commit

Permalink
still produce sym node, but give it the correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Dec 5, 2024
1 parent 71a60de commit c59d95c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/vmdeps.nim
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
result = newNodeX(nkDistinctTy)
result.add mapTypeToAst(t.skipModifier, info)
else:
if allowRecursion or t.sym == nil or tfFromGeneric in t.flags:
if allowRecursion or t.sym == nil:
result = mapTypeToBracket("distinct", mDistinct, t, info)
else:
result = atomicType(t.sym)
# keep original type, t.sym can have type tyGenericBody:
result.typ() = t
of tyGenericParam, tyForward:
result = atomicType(t.sym)
of tyObject:
Expand All @@ -181,7 +183,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
else:
result.add newNodeI(nkEmpty, info)
else:
if allowRecursion or t.sym == nil or tfFromGeneric in t.flags:
if allowRecursion or t.sym == nil:
result = newNodeIT(nkObjectTy, if t.n.isNil: info else: t.n.info, t)
result.add newNodeI(nkEmpty, info)
if t.baseClass == nil:
Expand All @@ -191,6 +193,8 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
result.add copyTree(t.n)
else:
result = atomicType(t.sym)
# keep original type, t.sym can have type tyGenericBody:
result.typ() = t
of tyEnum:
result = newNodeIT(nkEnumTy, if t.n.isNil: info else: t.n.info, t)
result.add newNodeI(nkEmpty, info) # pragma node, currently always empty for enum
Expand Down

0 comments on commit c59d95c

Please sign in to comment.