The following code generates a compile error and I'm confused as to why. Why 
doesn't the await keyword give me a string to work with in this case?
    
    
    import asyncdispatch
    
    proc fa(i: int): Future[string] =
      var fut = newFuture[string]("fa")
      fut.complete("fa: " & $i)
      result = fut
    
    proc fb(s: string): Future[string] =
      var fut = newFuture[string]("fb")
      fut.complete("fb: " & s)
      result = fut
    
    proc fc(i: int): Future[string] {.async.} =
      let a = await fa(i)
      result = fb(a)                # <-- compile error
    
    when isMainModule:
      echo(waitFor fa(3))
      echo(waitFor fb("main"))
      echo(waitFor fc(3))
    
    
    Run
    
    
    b1.nim(13, 35) template/generic instantiation of `async` from here
    b1.nim(15, 14) Error: type mismatch: got <Future[system.string]> but 
expected 'string'
    
    
    Run

Reply via email to