diff options
author | Anatoly Galiulin <galiulin.anatoly@gmail.com> | 2017-11-29 07:34:30 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-11-29 01:34:30 +0100 |
commit | c343303efeb063102d33bcb7d214b384f3dcd7df (patch) | |
tree | fdfee56e0ac9f4389ee397802e457cd477d88de2 | |
parent | 5a58caa9c15dd44a6208aa8d1e52d82033bb4510 (diff) | |
download | Nim-c343303efeb063102d33bcb7d214b384f3dcd7df.tar.gz |
Fix usage of parameters types in templates #6756 (#6768)
-rw-r--r-- | compiler/evaltempl.nim | 2 | ||||
-rw-r--r-- | tests/ccgbugs/t6756.nim | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim index 2c8abdfce..7fa6df3da 100644 --- a/compiler/evaltempl.nim +++ b/compiler/evaltempl.nim @@ -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) diff --git a/tests/ccgbugs/t6756.nim b/tests/ccgbugs/t6756.nim new file mode 100644 index 000000000..0f08557eb --- /dev/null +++ b/tests/ccgbugs/t6756.nim @@ -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)[] |