mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 11:24:08 +00:00
fixes #2215
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user