mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
fixes #22947
(cherry picked from commit 09ea1b168f)
This commit is contained in:
@@ -2239,7 +2239,7 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
|
||||
for i in 1..<ids.len:
|
||||
let exp = semExprWithType(c, quotes[i+1], {})
|
||||
let typ = exp.typ
|
||||
if tfTriggersCompileTime notin typ.flags and exp.kind == nkSym and exp.sym.kind notin routineKinds + {skType}:
|
||||
if tfTriggersCompileTime notin typ.flags and typ.kind != tyStatic and exp.kind == nkSym and exp.sym.kind notin routineKinds + {skType}:
|
||||
dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[i], newNodeIT(nkType, n.info, typ), c.graph.emptyNode)
|
||||
else:
|
||||
dummyTemplate[paramsPos].add newTreeI(nkIdentDefs, n.info, ids[i], getSysSym(c.graph, n.info, "typed").newSymNode, c.graph.emptyNode)
|
||||
|
||||
@@ -334,3 +334,16 @@ block:
|
||||
`hello`(12, type(x))
|
||||
|
||||
main()
|
||||
|
||||
block: # bug #22947
|
||||
macro bar[N: static int](a: var array[N, int]) =
|
||||
result = quote do:
|
||||
for i in 0 ..< `N`:
|
||||
`a`[i] = i
|
||||
|
||||
func foo[N: static int](a: var array[N, int]) =
|
||||
bar(a)
|
||||
|
||||
|
||||
var a: array[4, int]
|
||||
foo(a)
|
||||
|
||||
Reference in New Issue
Block a user