Fix usage of parameters types in templates #6756 (#6768)

This commit is contained in:
Anatoly Galiulin
2017-11-29 07:34:30 +07:00
committed by Andreas Rumpf
parent 5a58caa9c1
commit c343303efe
2 changed files with 19 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ proc evalTemplateAux(templ, actual: PNode, c: var TemplCtx, result: PNode) =
s.kind == skType and s.typ != nil and s.typ.kind == tyGenericParam:
handleParam actual.sons[s.owner.typ.len + s.position - 1]
else:
internalAssert sfGenSym in s.flags
internalAssert sfGenSym in s.flags or s.kind == skType
var x = PSym(idTableGet(c.mapping, s))
if x == nil:
x = copySym(s, false)

18
tests/ccgbugs/t6756.nim Normal file
View File

@@ -0,0 +1,18 @@
import typetraits
type
A[T] = ref object
v: T
template templ(o: A, op: untyped): untyped =
type T = type(o.v)
var res: A[T]
block:
var it {.inject.}: T
it = o.v
res = A[T](v: op)
res
let a = A[int](v: 1)
echo templ(a, it + 2)[]