Skip to content

Commit a627ae9

Browse files
committed
fix compile error from custom pragma template
1 parent 413f9a4 commit a627ae9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

compiler/sigmatch.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,8 +3005,12 @@ proc matchesAux(c: PContext, n, nOrig: PNode, m: var TCandidate, marker: var Int
30053005
m.typedescMatched = false
30063006
var newlyTyped = false
30073007
n[a] = prepareOperand(c, formal.typ, n[a], newlyTyped)
3008-
if (n[a].typ != nil and n[a].typ.kind == tyForward) or
3009-
(n[a].kind == nkSym and n[a].sym.typ != nil and n[a].sym.typ.kind == tyForward):
3008+
if ((n[a].typ != nil and n[a].typ.kind == tyForward) or
3009+
(n[a].kind == nkSym and n[a].sym.typ != nil and n[a].sym.typ.kind == tyForward)) and
3010+
not (m.calleeSym != nil and sfCustomPragma in m.calleeSym.flags):
3011+
# exclude custom pragma template (used as a pragma in a type section) to avoid generating compile errors from existing code
3012+
# maybe it should not be excluded if `formal.typ` is not generic.
3013+
30103014
# set tyForward type to `m.call.typ` so that caller can easily see this call contains a tyForward type param.
30113015
m.call.typ = if n[a].typ != nil and n[a].typ.kind == tyForward: n[a].typ else: n[a].sym.typ
30123016
noMatch(true)

0 commit comments

Comments
 (0)