Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression 'exit_14240299' has no type (or is ambiguous) #10

Closed
zevv opened this issue Jul 25, 2020 · 0 comments
Closed

expression 'exit_14240299' has no type (or is ambiguous) #10

zevv opened this issue Jul 25, 2020 · 0 comments

Comments

@zevv
Copy link
Collaborator

zevv commented Jul 25, 2020


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)```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant