This commit is contained in:
Araq
2015-02-25 20:32:32 +01:00
parent 335c19c869
commit f2cdbc92eb
3 changed files with 41 additions and 11 deletions

View File

@@ -31,3 +31,32 @@ var x: Something
testB(x)
# bug #2215
# Test that templates in generics still work (regression to fix the
# regression...)
template forStatic(index: expr, slice: Slice[int], predicate: stmt):
stmt {.immediate.} =
const a = slice.a
const b = slice.b
when a <= b:
template iteration(i: int) =
block:
const index = i
predicate
template iterateStartingFrom(i: int): stmt =
when i <= b:
iteration i
iterateStartingFrom i + 1
iterateStartingFrom a
proc concreteProc(x: int) =
forStatic i, 0..3:
echo i
proc genericProc(x: any) =
forStatic i, 0..3:
echo i
concreteProc(7) # This works
genericProc(7) # This doesn't compile