You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import cps
type C = ref object of RootObj
fn*: proc(c: C): C {.nimcall.}
proc add1(val: var int): C {.cpsMagic.} =
inc val
proc f(): C {.cps.} =
var a: int
cps add1(a)
if true:
cps add1(a)
if true:
cps add1(a)
doAssert a == 3
=== .cps. on f ===
type
env_14240156 = ref object {.cpsLift.}of C
a: int
proc after_14240296(locals_14240313: C): C =
proc after_14240307(locals_14240312: C): C =
proc after_14240307(locals_14240312: C): C =
## installing locals for env env
var a: int = env_14240156(locals_14240312).a
## add if body
if true:
return add1(env_14240156(fn: exit_14240299, a: a).C, a)
## post-cps call; time to bail
## split at: after - no body left
return env_14240156(fn: exit_14240299, a: a).C
## split at: maybe - no body left
return env_14240156(fn: exit_14240299, a: a).C
proc exit_14240299(locals_14240300: C): C =
proc exit_14240299(locals_14240300: C): C =
## installing locals for env env
var a: int = env_14240156(locals_14240300).a
doAssert a == 3
proc after_14240296(locals_14240313: C): C =
## installing locals for env env
var a: int = env_14240156(locals_14240313).a
if true:
return add1(env_14240156(fn: after_14240307, a: a).C, a)
## post-cps call; time to bail
## split at: after
## new tail call: after_14240307
return env_14240156(fn: after_14240307, a: a).C
## creating a new proc: after_14240307
## add the exit proc definition
## split at: exit
## new tail call: exit_14240299
return env_14240156(fn: exit_14240299, a: a).C
## creating a new proc: exit_14240299
proc f(): C =
var a: int
return add1(env_14240156(fn: after_14240296, a: a).C, a)
## post-cps call; time to bail
## split at: after
## new tail call: after_14240296
return env_14240156(fn: after_14240296, a: a).C
## creating a new proc: after_14240296
/home/ico/sandbox/prjs/cps/t.nim(10, 15) template/generic instantiation of `cps` from here
/home/ico/sandbox/prjs/cps/cps.nim(368, 21) Error: expression 'exit_14240299' has no type (or is ambiguous)```
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: