nim-works / cps

Continuation-Passing Style for Nim 🔗

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lifted variables are not initialized when entering scope

zevv opened this issue · comments

import cps

template testcode(name: string) =   
  echo "runnign in ", name
  var i = 0
  while i < 2:                   
    var j: int            
    echo j 
    j = 3     
    inc i     
          
proc test_cps() {.cps:Continuation.} =
  testcode("cps")

proc test_plain() =                   
  testcode("plain")

                             
test_plain()       

var f = whelp test_cps()
discard trampoline(f)
runnign in plain
0
0
runnign in cps
0
3