don't set sym of generic param type value to generic param sym (#24995)

fixes #23713

`linkTo` normally sets the sym of the type as well as the type of the
sym, but this is not wanted for custom pragmas as it would look up the
definition of the generic param and not the definition of its value. I
don't see a practical use for this either.

(cherry picked from commit 7701b3c7e6)
This commit is contained in:
metagn
2025-06-13 01:03:02 +03:00
committed by narimiran
parent 114d0b8bdc
commit c467532484
2 changed files with 19 additions and 2 deletions

View File

@@ -1345,7 +1345,9 @@ proc readTypeParameter(c: PContext, typ: PType,
# This seems semantically correct and then we'll be able
# to return the section symbol directly here
let foundType = makeTypeDesc(c, def[2].typ)
return newSymNode(copySym(def[0].sym, c.idgen).linkTo(foundType), info)
let s = copySym(def[0].sym, c.idgen)
s.typ = foundType
return newSymNode(s, info)
of nkConstSection:
for def in statement:
@@ -1370,7 +1372,9 @@ proc readTypeParameter(c: PContext, typ: PType,
return c.graph.emptyNode
else:
let foundTyp = makeTypeDesc(c, rawTyp)
return newSymNode(copySym(tParam.sym, c.idgen).linkTo(foundTyp), info)
let s = copySym(tParam.sym, c.idgen)
s.typ = foundTyp
return newSymNode(s, info)
return nil

View File

@@ -0,0 +1,13 @@
# issue #23713
import std/macros
template p {.pragma.}
type
X {.p.} = object
Y[T] = object
t: T
doAssert Y[X].T.hasCustomPragma(p)