Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give bare generic sym node from getType of object/distinct an instantiated type #24511

Draft
wants to merge 4 commits into
base: devel
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions compiler/vmdeps.nim
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
if inst:
if allowRecursion:
result = mapTypeToAstR(t.skipModifier, info)
# keep original type info for getType calls on the output node:
result.typ() = t
else:
result = newNodeX(nkBracketExpr)
#result.add mapTypeToAst(t.last, info)
Expand All @@ -145,8 +143,6 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
result.add mapTypeToAst(a, info)
else:
result = mapTypeToAstX(cache, t.skipModifier, info, idgen, inst, allowRecursion)
# keep original type info for getType calls on the output node:
result.typ() = t
of tyGenericBody:
if inst:
result = mapTypeToAstR(t.typeBodyImpl, info)
Expand All @@ -165,6 +161,9 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
result = mapTypeToBracket("distinct", mDistinct, t, info)
else:
result = atomicType(t.sym)
if tfFromGeneric in t.flags and t.sym.typ.kind == tyGenericBody:
# keep original type, t.sym can have type tyGenericBody:
result.typ() = t
of tyGenericParam, tyForward:
result = atomicType(t.sym)
of tyObject:
Expand Down Expand Up @@ -195,6 +194,9 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
result.add copyTree(t.n)
else:
result = atomicType(t.sym)
if tfFromGeneric in t.flags and t.sym.typ.kind == tyGenericBody:
# 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
Loading