nim-works / cps

Continuation-Passing Style for Nim 🔗

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

whelp can't process `borrow-ed` symbols

alaviss opened this issue · comments

import cps

type
  D = distinct int

proc bar(x: int) {.cps: Continuation.} =
  discard

proc bar(d: D) {.borrow.}

discard whelp bar(D(42))

gets:

cps.nim(115, 16) Error: node is not a symbol

here's treeRepr of getImpl() of the callee:

ProcDef
  Sym "bar"
  Empty
  Empty
  FormalParams
    Empty
    IdentDefs
      Sym "d"
      Sym "D"
      Empty
  Pragma
    Ident "borrow"
  Empty
  Sym "bar"

The last symbol points to the borrowed proc. We should be able to use this, somehow.

It looks trivial if we have the source symbol; it's just a if and a recursion in whelp.