From 71a60de5885a54fee6d7be01acb99d5d2ef46659 Mon Sep 17 00:00:00 2001 From: metagn Date: Thu, 5 Dec 2024 07:02:55 +0300 Subject: [PATCH] fix getType on object/distinct types giving bare generic sym fixes #24503, refs #22655, refs #24509 --- compiler/vmdeps.nim | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 1803d4d6217fe..ba5cde8fc1535 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -135,8 +135,6 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; if inst: if allowRecursion: result = mapTypeToAstR(t.skipModifier, info) - # result.typ can be tyGenericBody, give it a proper type: - result.typ() = t.skipModifier else: result = newNodeX(nkBracketExpr) #result.add mapTypeToAst(t.last, info) @@ -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) - # result.typ can be tyGenericBody, give it a proper type: - result.typ() = t.skipModifier of tyGenericBody: if inst: result = mapTypeToAstR(t.typeBodyImpl, info) @@ -161,7 +157,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; result = newNodeX(nkDistinctTy) result.add mapTypeToAst(t.skipModifier, info) else: - if allowRecursion or t.sym == nil: + if allowRecursion or t.sym == nil or tfFromGeneric in t.flags: result = mapTypeToBracket("distinct", mDistinct, t, info) else: result = atomicType(t.sym) @@ -185,7 +181,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; else: result.add newNodeI(nkEmpty, info) else: - if allowRecursion or t.sym == nil: + if allowRecursion or t.sym == nil or tfFromGeneric in t.flags: result = newNodeIT(nkObjectTy, if t.n.isNil: info else: t.n.info, t) result.add newNodeI(nkEmpty, info) if t.baseClass == nil: