mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
13
tests/pragmas/tgenericparamcustompragma.nim
Normal file
13
tests/pragmas/tgenericparamcustompragma.nim
Normal 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)
|
||||
Reference in New Issue
Block a user