parent
913ffbb92d
commit
d938c6411e
2 changed files with 71 additions and 55 deletions
|
|
@ -2055,13 +2055,21 @@ proc semGenericConstraints(c: PContext, x: PType): PType =
|
||||||
result = newTypeWithSons(c, tyGenericParam, @[x])
|
result = newTypeWithSons(c, tyGenericParam, @[x])
|
||||||
|
|
||||||
proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
||||||
|
|
||||||
|
template addSym(result: PNode, s: PSym): untyped =
|
||||||
|
if father != nil: addSonSkipIntLit(father, s.typ)
|
||||||
|
if sfGenSym notin s.flags: addDecl(c, s)
|
||||||
|
result.add newSymNode(s)
|
||||||
|
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
if n.kind != nkGenericParams:
|
if n.kind != nkGenericParams:
|
||||||
illFormedAst(n, c.config)
|
illFormedAst(n, c.config)
|
||||||
return
|
return
|
||||||
for i in 0..<n.len:
|
for i in 0..<n.len:
|
||||||
var a = n[i]
|
var a = n[i]
|
||||||
if a.kind != nkIdentDefs: illFormedAst(n, c.config)
|
case a.kind
|
||||||
|
of nkSym: result.addSym(a.sym)
|
||||||
|
of nkIdentDefs:
|
||||||
var def = a[^1]
|
var def = a[^1]
|
||||||
let constraint = a[^2]
|
let constraint = a[^2]
|
||||||
var typ: PType
|
var typ: PType
|
||||||
|
|
@ -2120,7 +2128,7 @@ proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
||||||
|
|
||||||
if covarianceFlag != tfUnresolved: s.typ.flags.incl(covarianceFlag)
|
if covarianceFlag != tfUnresolved: s.typ.flags.incl(covarianceFlag)
|
||||||
if def.kind != nkEmpty: s.ast = def
|
if def.kind != nkEmpty: s.ast = def
|
||||||
if father != nil: addSonSkipIntLit(father, s.typ)
|
|
||||||
s.position = result.len
|
s.position = result.len
|
||||||
result.add newSymNode(s)
|
result.addSym(s)
|
||||||
if sfGenSym notin s.flags: addDecl(c, s)
|
else:
|
||||||
|
illFormedAst(n, c.config)
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,11 @@ const t = mac("HEllo World")
|
||||||
echo s, " ", t
|
echo s, " ", t
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# issue #15326
|
||||||
|
macro m(n:typed):auto =
|
||||||
|
result = n
|
||||||
|
|
||||||
|
proc f[T](x:T): T {.m.} = x
|
||||||
|
|
||||||
|
discard f(3)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue