Skip to content

Commit 7701b3c

Browse files
authored
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.
1 parent 151b903 commit 7701b3c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

compiler/semexprs.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,9 @@ proc readTypeParameter(c: PContext, typ: PType,
12921292
# This seems semantically correct and then we'll be able
12931293
# to return the section symbol directly here
12941294
let foundType = makeTypeDesc(c, def[2].typ)
1295-
return newSymNode(copySym(def[0].sym, c.idgen).linkTo(foundType), info)
1295+
let s = copySym(def[0].sym, c.idgen)
1296+
s.typ = foundType
1297+
return newSymNode(s, info)
12961298

12971299
of nkConstSection:
12981300
for def in statement:
@@ -1317,7 +1319,9 @@ proc readTypeParameter(c: PContext, typ: PType,
13171319
return c.graph.emptyNode
13181320
else:
13191321
let foundTyp = makeTypeDesc(c, rawTyp)
1320-
return newSymNode(copySym(tParam.sym, c.idgen).linkTo(foundTyp), info)
1322+
let s = copySym(tParam.sym, c.idgen)
1323+
s.typ = foundTyp
1324+
return newSymNode(s, info)
13211325

13221326
return nil
13231327

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# issue #23713
2+
3+
import std/macros
4+
5+
template p {.pragma.}
6+
7+
type
8+
X {.p.} = object
9+
10+
Y[T] = object
11+
t: T
12+
13+
doAssert Y[X].T.hasCustomPragma(p)

0 commit comments

Comments
 (0)