mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 06:20:38 +00:00
* Fixes #9365 : let with exportC pragma in template. * Fix according to comments.
This commit is contained in:
committed by
Andreas Rumpf
parent
55cf971adf
commit
a6d4421241
@@ -197,6 +197,12 @@ proc addLocalDecl(c: var TemplCtx, n: var PNode, k: TSymKind) =
|
||||
else:
|
||||
replaceIdentBySym(c.c, n, ident)
|
||||
else:
|
||||
if (n.kind == nkPragmaExpr and sonsLen(n) >= 2 and n.sons[1].kind == nkPragma):
|
||||
let pragmaNode = n.sons[1]
|
||||
for i in 0..<pragmaNode.sons.len:
|
||||
openScope(c)
|
||||
pragmaNode.sons[i] = semTemplBody(c,pragmaNode.sons[i])
|
||||
closeScope(c)
|
||||
let ident = getIdentNode(c, n)
|
||||
if not isTemplParam(c, ident):
|
||||
# fix #2670, consider:
|
||||
|
||||
9
tests/template/template_pragmas.nim
Normal file
9
tests/template/template_pragmas.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
proc output_x:string {.compileTime.} = "x"
|
||||
|
||||
template t =
|
||||
const x = output_x()
|
||||
let
|
||||
bar {.exportC:"bar" & x.} = 100
|
||||
|
||||
static:
|
||||
doAssert(compiles (t()))
|
||||
Reference in New Issue
Block a user