Skip to content

Error calling continuation object/tuple field callback. #337

@quantimnot

Description

@quantimnot
import pkg/cps

var wait: Continuation

proc a(x: int): int {.cps: Continuation.} =
  x * 2

type
  Fn = proc (x: int): int {.cps: Continuation.}
  Calc = object
    fn: Fn

proc worksAsNormal(fn: Fn): int {.cps: Continuation.} =
  fn(10)

proc workaround(c: Calc): int {.cps: Continuation.} =
  let fn = c.fn
  fn(10)

proc fails1(c: Calc): int {.cps: Continuation.} =
  c.fn(10) #[tt.Error
   ^ attempting to call undeclared routine: 'fn']#

proc fails2(c: Calc): int {.cps: Continuation.} =
  template fun(x): untyped = c.fn(x) #[tt.Error
                              ^ attempting to call undeclared routine: 'fn']#
  fun(10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions