Skip to content

scala.NotImplementedError when evaluating a failed Future #66

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

Closed
yanns opened this issue Mar 26, 2014 · 4 comments
Closed

scala.NotImplementedError when evaluating a failed Future #66

yanns opened this issue Mar 26, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@yanns
Copy link

yanns commented Mar 26, 2014

The following worksheet:

import scala.async.Async.{async, await}
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

val f = Future.failed(new Exception())
async {
  await(f)
}

delivers the following error

scala.NotImplementedError: an implementation is missing
    at scala.Predef$.$qmark$qmark$qmark(async.sc1820668219168430883.tmp:248)
    at #worksheet#.stateMachine$1$1.<init>(async.sc1820668219168430883.tmp:7)
    at #worksheet#.#worksheet#(async.sc1820668219168430883.tmp:6)
@retronym retronym added this to the 0.9.2 milestone Apr 15, 2014
@kovacshuni
Copy link

What is the status on this. It seems to be a pretty important case of the whole async/await flow. If Exceptions cannot be thrown, then how should i have the courage to use this lib?

@retronym
Copy link
Member

Thanks for the report. You can workaround this issue by annotating the type if f with something other than Future[Nothing].

val f: Future[Any] = Future.failed(new Exception())
async {
  await(f)
}

I'll include the fix for this bug in a new release of async in the coming weeks.

@yanns
Copy link
Author

yanns commented Jul 2, 2014

I can confirm the workaround works.

import scala.async.Async.{async, await}
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global

val f: Future[String] = Future.failed(new Exception("test"))
val result = async {
  await(f)
}
Await.result(result, Duration.Inf)

outputs

import scala.async.Async.{async, await}
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global

f: scala.concurrent.Future[String] = scala.concurrent.impl.Promise$KeptPromise@68c8af42
result: scala.concurrent.Future[String] = scala.concurrent.impl.Promise$DefaultPromise@7d52966f


java.lang.Exception: test
    at #worksheet#.f$lzycompute(async.sc3389584584737533063.tmp:6)
    at #worksheet#.f(async.sc3389584584737533063.tmp:6)
    at #worksheet#.get$$instance$$f(async.sc3389584584737533063.tmp:6)
    at #worksheet#.#worksheet#(async.sc3389584584737533063.tmp:25)

It means that his error would never occur in real application code.
Great!

retronym added a commit to retronym/async that referenced this issue Jul 21, 2014
This progressed along with the fix for scala#66.

`TreeGen.mkZero` is a bit of a minefield: first with `Nothing` and
now with Value Classes. I wonder if we can provoke the same sort of
bug in the compiler in places where this is used.

Closes scala#83
@retronym
Copy link
Member

I've just deployed scala-async 0.9.2 to Sonatype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants