Skip to content

NotImplementedError is being thrown in... #120

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
dwhjames opened this issue Jul 17, 2015 · 2 comments
Closed

NotImplementedError is being thrown in... #120

dwhjames opened this issue Jul 17, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@dwhjames
Copy link

... this example

scala> :paste
// Entering paste mode (ctrl-D to finish)

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

def broken() = async {
  if (true) {
    val n = await(async(1))
    if (n < 2) {
      throw new RuntimeException("case a")
    }
    else {
      throw new RuntimeException("case b")
    }
  }
  else {
    "case c"
  }
}

// Exiting paste mode, now interpreting.

import scala.async.Async._
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
broken: ()scala.concurrent.Future[String]

scala> println(Await.result(broken(), Duration("1 second")))
scala.NotImplementedError: an implementation is missing
  at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
  at stateMachine$macro$2$1.apply(<console>:15)
  at stateMachine$macro$2$1.apply(<console>:12)
  at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
  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)

Maybe related to #104 and #66?

A workaround for this issue is to provide an explicit return type of Future[String] to the method.

retronym added a commit to retronym/async that referenced this issue Jul 27, 2015
Code like:

    val x = if (cond) throw new A else throw new B

Was being transformed to:

   val ifRes = ???
   if (cond) ifRes = throw new A else ifRes = throw new B
   val x = ifRes

by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing`

This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions.
The example above is now translated to:

    if (cond) throw new A else throw new B
    val x = throw new IllegalStateException()

Fixed scala#120
@retronym retronym self-assigned this Jul 27, 2015
@retronym retronym added the bug label Jul 27, 2015
@retronym retronym added this to the 0.9.5 milestone Jul 27, 2015
retronym added a commit to retronym/async that referenced this issue Jul 27, 2015
Code like:

    val x = if (cond) throw new A else throw new B

Was being transformed to:

   val ifRes = ???
   if (cond) ifRes = throw new A else ifRes = throw new B
   val x = ifRes

by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing`

This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions.
The example above is now translated to:

    if (cond) throw new A else throw new B
    val x = throw new IllegalStateException()

Fixed scala#120
retronym added a commit to retronym/async that referenced this issue Jul 27, 2015
Code like:

    val x = if (cond) throw new A else throw new B

Was being transformed to:

   val ifRes = ???
   if (cond) ifRes = throw new A else ifRes = throw new B
   val x = ifRes

by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing`

This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions.
The example above is now translated to:

    if (cond) throw new A else throw new B
    val x = throw new IllegalStateException()

Fixed scala#120
retronym added a commit to retronym/async that referenced this issue Jul 27, 2015
Code like:

    val x = if (cond) throw new A else throw new B

Was being transformed to:

    val ifRes = ???
    if (cond) ifRes = throw new A else ifRes = throw new B
    val x = ifRes

by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing`

This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions.
The example above is now translated to:

    if (cond) throw new A else throw new B
    val x = throw new IllegalStateException()

Fixes scala#120
retronym added a commit to retronym/async that referenced this issue Jul 27, 2015
Code like:

    val x = if (cond) throw new A else throw new B

Was being transformed to:

    val ifRes = ???
    if (cond) ifRes = throw new A else ifRes = throw new B
    val x = ifRes

by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing`

This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions.
The example above is now translated to:

    if (cond) throw new A else throw new B
    val x = throw new IllegalStateException()

Fixes scala#120

(cherry picked from commit 80aaf18)
@retronym
Copy link
Member

Hi @dwhjames,

Thanks for the bug report. Would you please be able to retest against the latest master or 2.10.x branch? I believe that I've fixed this bug, but would like to confirm that this fix is enough for you.

@dwhjames
Copy link
Author

Thanks @retronym, yes, I believe this has fixed the issued. I removed the explicit return type and there was no NotImplementedError thrown.

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