Here's the test that runs against the almost branch:
https://github.com/disruptek/cps/blob/almost/tests/fors.nim
import testes
import cps
type
C = ref object of RootObj
fn*: proc(c: C): C {.nimcall.}
proc trampoline(c: C) =
var c = c
while c != nil and c.fn != nil:
c = c.fn(c)
testes:
block:
proc loop() {.cps: C.} =
for i in 0 .. 3:
discard
trampoline loop()
Here's the broken rewrite; CPS doesn't know what to do with the var i statement. I don't even understand how it passes through sem successfully to reach our macro...
16 proc foo() =
17 block :tmp:
18 var i
19 ## An alias for `countup(a, b, 1)`.
20 ##
21 ## See also:
22 ## * [..<](#..<.i,T,T)
23 var res = 0
24 block :tmp:
25 while res <= 3:
26 i = T(res)
27 discard
28 inc(res, 1)
Here's the test that runs against the
almostbranch:https://github.com/disruptek/cps/blob/almost/tests/fors.nim
Here's the broken rewrite; CPS doesn't know what to do with the
var istatement. I don't even understand how it passes through sem successfully to reach our macro...