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

await on a Future[Nothing] can cause NotImplementedError #104

Closed
ewiner opened this issue Feb 6, 2015 · 1 comment
Closed

await on a Future[Nothing] can cause NotImplementedError #104

ewiner opened this issue Feb 6, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@ewiner
Copy link

ewiner commented Feb 6, 2015

I have some code that makes an async call do decide which exception to throw. This seems to generate an assignment to ??? in the calling method when that exception state is skipped.

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

def errorGenerator(randomNum: Double) = {
  Future {
    if (randomNum < 0) {
      throw new IllegalStateException("Random number was too low!")
    } else {
      throw new IllegalStateException("Random number was too high!")
    }
  }
}
def randomTimesTwo = async {
  val num = math.random
  if (num < 0 || num > 1) {
    await(errorGenerator(num))
  }

  num * 2
}

println(Await.result(randomTimesTwo, Duration("1 second")))

results in

java.util.concurrent.ExecutionException: Boxed Error
    at scala.concurrent.impl.Promise$.resolver(Promise.scala:55)
    at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:47)
    at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:244)
    at scala.concurrent.Promise$class.complete(Promise.scala:55)
    at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153)
    at A$A110$A$A110$stateMachine$macro$1$1.resume(playground.sc0.tmp:20)
    at A$A110$A$A110$stateMachine$macro$1$1.resume(playground.sc0.tmp:20)
    at A$A110$A$A110$stateMachine$macro$1$1.apply$mcV$sp(playground.sc0.tmp:20)
    at A$A110$A$A110$stateMachine$macro$1$1.apply(playground.sc0.tmp:20)
    at A$A110$A$A110$stateMachine$macro$1$1.apply(playground.sc0.tmp:20)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
    at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: scala.NotImplementedError: an implementation is missing
    at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
    ... 12 more

Tried this on async 0.9.2 & 0.9.3, Scala 2.11.4.

@retronym
Copy link
Member

retronym commented Feb 6, 2015

Darn, I thought I'd fixed this as #66.

@retronym retronym added the bug label Jul 6, 2015
@retronym retronym added this to the 0.9.4 milestone Jul 6, 2015
@retronym retronym self-assigned this Jul 6, 2015
retronym added a commit that referenced this issue Jul 6, 2015
This commit disabled live variable analysis for intermediate values of type Nothing.

Fixes #104
retronym added a commit to retronym/async that referenced this issue Jul 6, 2015
…ure[Nothing]

This commit disabled live variable analysis for intermediate values of type Nothing.

Fixes scala#104

(cherry picked from commit 6353443)
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

2 participants