diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index a9cb598262..1c1cbdec99 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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 diff --git a/tests/pragmas/tgenericparamcustompragma.nim b/tests/pragmas/tgenericparamcustompragma.nim new file mode 100644 index 0000000000..d629f49324 --- /dev/null +++ b/tests/pragmas/tgenericparamcustompragma.nim @@ -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)