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

REPL gets confused about results #9710

Closed
scabug opened this Issue Mar 17, 2016 · 3 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Mar 17, 2016

Enter the following sequence in the REPL:

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
val f = Future { 4 / 0 }
for (exc <- f.failed) println(exc)
val f = Future { 4 / 2 }
val f = Future { 4 / 0 }
for (exc <- f.failed) println(exc)
val f = Future { 4 / 0 }

The last line will evaluate as:

scala> val f = Future { 4 / 0 }
f: scala.concurrent.Future[Int] = List()

which is not possible as an empty list is not a Future.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Mar 17, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9710?orig=1
Reporter: Samuel Tardieu (rfc1149)
Affected Versions: 2.11.8
Duplicates #9488

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Mar 17, 2016

Li Haoyi (lihaoyi) said (edited on Mar 17, 2016 4:30:24 PM UTC):
Seems to be fixed in the Ammonite REPL?

haoyi-mbp:blog haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.6
(Scala 2.11.7 Java 1.8.0_25)
@ import scala.concurrent.Future
import scala.concurrent.Future
@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.ExecutionContext.Implicits.global
@ val f = Future { 4 / 0 }
f: Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@7a17ffee
@ for (exc <- f.failed) println(exc)
java.lang.ArithmeticException: / by zero

@ val f = Future { 4 / 2 }
f: Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@24347d8b
@ val f = Future { 4 / 0 }
f: Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@6d810e94
@ for (exc <- f.failed) println(exc)
java.lang.ArithmeticException: / by zero

@ val f = Future { 4 / 0 }
f: Future[Int] = scala.concurrent.impl.Promise$DefaultPromise@142dbf1a
@
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Mar 17, 2016

@som-snytt said:
Nothing to do with the REPL, obviously.

@scabug scabug closed this Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment