fixes tmemit regression
This commit is contained in:
parent
a1e97ad4a4
commit
dc956c485a
2 changed files with 29 additions and 1 deletions
|
|
@ -232,6 +232,18 @@ proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind) =
|
||||||
for j in countup(0, L-3):
|
for j in countup(0, L-3):
|
||||||
addLocalDecl(c, a.sons[j], symKind)
|
addLocalDecl(c, a.sons[j], symKind)
|
||||||
|
|
||||||
|
proc onlyReplaceParams(c: var TemplCtx, n: PNode): PNode =
|
||||||
|
result = n
|
||||||
|
if n.kind == nkIdent:
|
||||||
|
let s = qualifiedLookUp(c.c, n, {})
|
||||||
|
if s != nil:
|
||||||
|
if s.owner == c.owner and s.kind == skParam:
|
||||||
|
incl(s.flags, sfUsed)
|
||||||
|
result = newSymNode(s, n.info)
|
||||||
|
else:
|
||||||
|
for i in 0 .. <n.safeLen:
|
||||||
|
result.sons[i] = onlyReplaceParams(c, n.sons[i])
|
||||||
|
|
||||||
proc semPattern(c: PContext, n: PNode): PNode
|
proc semPattern(c: PContext, n: PNode): PNode
|
||||||
proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
@ -365,6 +377,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
result.sons[0] = semTemplBody(c, n.sons[0])
|
result.sons[0] = semTemplBody(c, n.sons[0])
|
||||||
of nkPostfix:
|
of nkPostfix:
|
||||||
result.sons[1] = semTemplBody(c, n.sons[1])
|
result.sons[1] = semTemplBody(c, n.sons[1])
|
||||||
|
of nkPragma:
|
||||||
|
result = onlyReplaceParams(c, n)
|
||||||
else:
|
else:
|
||||||
# dotExpr is ambiguous: note that we explicitely allow 'x.TemplateParam',
|
# dotExpr is ambiguous: note that we explicitely allow 'x.TemplateParam',
|
||||||
# so we use the generic code for nkDotExpr too
|
# so we use the generic code for nkDotExpr too
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,21 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''HELLO WORLD'''
|
output: '''HELLO WORLD
|
||||||
|
c_func'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import macros, strutils
|
import macros, strutils
|
||||||
|
|
||||||
emit("echo " & '"' & "hello world".toUpper & '"')
|
emit("echo " & '"' & "hello world".toUpper & '"')
|
||||||
|
|
||||||
|
# bug #1025
|
||||||
|
|
||||||
|
macro foo(icname): stmt =
|
||||||
|
let ic = newStrLitNode($icname)
|
||||||
|
result = quote do:
|
||||||
|
proc x* =
|
||||||
|
proc private {.exportc: `ic`.} = discard
|
||||||
|
echo `ic`
|
||||||
|
private()
|
||||||
|
|
||||||
|
foo(c_func)
|
||||||
|
x()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue