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 'brake_16985017' has no type (or is ambiguous) #11

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

expression 'brake_16985017' has no type (or is ambiguous) #11

zevv opened this issue Jul 25, 2020 · 0 comments

Comments

@zevv
Copy link
Collaborator

zevv commented Jul 25, 2020

Related to #10?

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)
      block:     
        cps add1(a)
        break      
        cps add1(a)  
      doAssert a == 2

=== .cps. on t ===

type
  env_16985002 = ref object {.cpsLift.}of C
    a: int

proc after_16985016(locals_16985029: C): C =
  
proc after_16985023(locals_16985026: C): C =
  
proc after_16985023(locals_16985026: C): C =
  ## installing locals for env env
  var a: int = env_16985002(locals_16985026).a
  ## simple break statement
  return env_16985002(fn: brake_16985017, a: a).C
  return add1(env_16985002(fn: nil, a: a).C, a)
  ## post-cps call; time to bail
  ## split at: after - no body left
  return nil

proc tail_16985027(locals_16985028: C): C =
  
proc brake_16985017(locals_16985018: C): C =
  
proc brake_16985017(locals_16985018: C): C =
  ## installing locals for env env
  var a: int = env_16985002(locals_16985018).a
  doAssert a == 2

proc tail_16985027(locals_16985028: C): C =
  ## installing locals for env env
  var a: int = env_16985002(locals_16985028).a
  ## split at: brake
  ## new tail call: brake_16985017
  return env_16985002(fn: brake_16985017, a: a).C
  ## creating a new proc: brake_16985017
  
proc after_16985016(locals_16985029: C): C =
  ## installing locals for env env
  var a: int = env_16985002(locals_16985029).a
  block:
    return add1(env_16985002(fn: after_16985023, a: a).C, a)
    ## post-cps call; time to bail
    ## split at: after
    ## new tail call: after_16985023
    return env_16985002(fn: after_16985023, a: a).C
    ## creating a new proc: after_16985023
  ## add tail call for block-break proc
  ## new tail call: tail_16985027
  return env_16985002(fn: tail_16985027, a: a).C
  ## creating a new proc: tail_16985027
  
proc t(): C =
  var a: int
  return add1(env_16985002(fn: after_16985016, a: a).C, a)
  ## post-cps call; time to bail
  ## split at: after
  ## new tail call: after_16985016
  return env_16985002(fn: after_16985016, a: a).C
  ## creating a new proc: after_16985016
  
/home/ico/sandbox/prjs/cps/tests/tzevv.nim(32, 7) template/generic instantiation of `suite` from here
/home/ico/sandbox/prjs/cps/tests/tzevv.nim(138, 8) template/generic instantiation of `test` from here
/home/ico/sandbox/prjs/cps/tests/tzevv.nim(139, 5) template/generic instantiation of `runCps` from here
/home/ico/sandbox/prjs/cps/tests/tzevv.nim(23, 17) template/generic instantiation of `cps` from here
/home/ico/sandbox/prjs/cps/cps.nim(368, 21) Error: expression 'brake_16985017' has no type (or is ambiguous)
@zevv zevv closed this as completed Jul 25, 2020
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