fixes #8052
This commit is contained in:
parent
2c8361bd39
commit
e09eeb02bf
2 changed files with 24 additions and 1 deletions
|
|
@ -210,7 +210,7 @@ proc addLocalDecl(c: var TemplCtx, n: var PNode, k: TSymKind) =
|
||||||
if s != nil and s.owner == c.owner and sfGenSym in s.flags:
|
if s != nil and s.owner == c.owner and sfGenSym in s.flags:
|
||||||
styleCheckUse(n.info, s)
|
styleCheckUse(n.info, s)
|
||||||
replaceIdentBySym(c.c, n, newSymNode(s, n.info))
|
replaceIdentBySym(c.c, n, newSymNode(s, n.info))
|
||||||
else:
|
elif not (n.kind == nkSym and sfGenSym in n.sym.flags):
|
||||||
let local = newGenSym(k, ident, c)
|
let local = newGenSym(k, ident, c)
|
||||||
addPrelimDecl(c.c, local)
|
addPrelimDecl(c.c, local)
|
||||||
styleCheckDef(c.c.config, n.info, local)
|
styleCheckDef(c.c.config, n.info, local)
|
||||||
|
|
|
||||||
23
tests/template/tnested_template.nim
Normal file
23
tests/template/tnested_template.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# bug #8052
|
||||||
|
|
||||||
|
type
|
||||||
|
UintImpl*[N: static[int], T: SomeUnsignedInt] = object
|
||||||
|
raw_data*: array[N, T]
|
||||||
|
|
||||||
|
template genLoHi(TypeImpl: untyped): untyped =
|
||||||
|
template loImpl[N: static[int], T: SomeUnsignedInt](dst: TypeImpl[N div 2, T], src: TypeImpl[N, T]) =
|
||||||
|
let halfSize = N div 2
|
||||||
|
for i in 0 ..< halfSize:
|
||||||
|
dst.raw_data[i] = src.raw_data[i]
|
||||||
|
|
||||||
|
proc lo*[N: static[int], T: SomeUnsignedInt](x: TypeImpl[N,T]): TypeImpl[N div 2, T] {.inline.}=
|
||||||
|
loImpl(result, x)
|
||||||
|
|
||||||
|
genLoHi(UintImpl)
|
||||||
|
|
||||||
|
var a: UintImpl[4, uint32]
|
||||||
|
|
||||||
|
a.raw_data = [1'u32, 2'u32, 3'u32, 4'u32]
|
||||||
|
assert a.lo.raw_data.len == 2
|
||||||
|
assert a.lo.raw_data[0] == 1
|
||||||
|
assert a.lo.raw_data[1] == 2
|
||||||
Loading…
Add table
Add a link
Reference in a new issue