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

Handle inner procs #223

Closed
zevv opened this issue Jul 25, 2021 · 3 comments
Closed

Handle inner procs #223

zevv opened this issue Jul 25, 2021 · 3 comments
Labels
enhancement New feature or request nim compiler defect fault lies elsewhere

Comments

@zevv
Copy link
Collaborator

zevv commented Jul 25, 2021

import cps    
import strutils
                                                             
type              
  C = Continuation
                  
  CallBack = proc(): C
          
proc bar(cb: CallBack) {.cps:C.} =                                                      
  echo "bar"
                      
proc thing() {.cps:C.} =
  echo "thing"
                                                                          
proc foo() {.cps:C.} =         
  proc gen(): CallBack =
    result = proc(): C =
      whelp thing()     
  bar gen()        
           
foo()
$ nim r /tmp/t.nim 
Hint: used config file '/home/ico/external/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/ico/external/Nim/config/config.nims' [Conf]
..............................................................................
/home/ico/sandbox/prjs/cps/cps/environment.nim(390, 16) Warning: pending https://github.com/nim-lang/Nim/issues/17851 [User]
..
/home/ico/sandbox/prjs/cps/cps/transform.nim(1138, 12) Warning: compiler bug workaround, see: https://github.com/nim-lang/Nim/issues/18349 [User]
..
/home/ico/sandbox/prjs/cps/cps/exprs.nim(176, 13) template/generic instantiation of `filterExpr` from here
/home/ico/sandbox/prjs/cps/cps/exprs.nim(107, 14) Warning: compiler workaround here, see: https://github.com/nim-lang/Nim/issues/18351 [User]
/home/ico/sandbox/prjs/cps/cps/exprs.nim(176, 13) template/generic instantiation of `filterExpr` from here
/home/ico/sandbox/prjs/cps/cps/exprs.nim(118, 14) Warning: compiler workaround here, see: https://github.com/nim-lang/Nim/issues/18351 [User]
/home/ico/sandbox/prjs/cps/cps/exprs.nim(323, 12) Warning: compiler workaround here, see: https://github.com/nim-lang/Nim/issues/18352 [User]
/home/ico/sandbox/prjs/cps/cps.nim(12, 12) Warning: cps supports --gc:arc or --gc:orc only; see https://github.com/nim-lang/Nim/issues/18099 [User]
/home/ico/sandbox/prjs/cps/cps.nim(17, 12) Warning: cps supports --panics:on only;  see https://github.com/disruptek/cps/issues/110 [User]
/home/ico/sandbox/prjs/cps/cps.nim(69, 16) Warning: compiler bug workaround, see: https://github.com/nim-lang/Nim/issues/18349 [User]
.........
/tmp/t.nim(16, 14) template/generic instantiation of `cps` from here
/tmp/t.nim(17, 3) Error: incorrect result proc symbol
@disruptek disruptek added the enhancement New feature or request label Aug 1, 2021
@disruptek disruptek added the nim compiler defect fault lies elsewhere label Aug 8, 2021
@disruptek
Copy link
Contributor

Seems to be a compiler bug.

/home/adavidoff/git/Nim/compiler/semstmts.nim(1636) maybeAddResult
/home/adavidoff/git/Nim/compiler/semstmts.nim(1490) addResult
/home/adavidoff/git/Nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: 'sym' is not accessible using discriminant 'kind' of type 'TNode' [FieldDefect]

Maybe we simply need to strip the pesky result symbol from all internal procdefs as a workaround pass?

/cc @alaviss

@disruptek
Copy link
Contributor

Stripping the result symbol didn't help, FWIW.

@disruptek
Copy link
Contributor

Works as of 2177537.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nim compiler defect fault lies elsewhere
Projects
None yet
Development

No branches or pull requests

2 participants