tut icon indicating copy to clipboard operation
tut copied to clipboard

tut:fail is failing

Open wheaties opened this issue 9 years ago • 4 comments

The following code taken verbatim from some documentation I'm trying to tut:fail

import concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

def something[A](futL: Future[List[Int]])(f: Int => A): Future[List[A]] = for{
  list <- futL
  item <- list //won't compile since "list" isn't a Future and hence, doesn't compose!
} yield f(item)

gives me the following output:

[tut] *** Error reported at Transformers.md:17: failure was asserted but no failure occurred
import concurrent.Future
[tut] *** Error reported at Transformers.md:18: failure was asserted but no failure occurred
import scala.concurrent.ExecutionContext.Implicits.global

I'm assuming this is a bug or is it supposed to be overeager? Removing the :fail causes the expected compilation errors.

wheaties avatar Jul 12 '15 15:07 wheaties

Ah, yeah. Hell. The way it's written fail expects every statement in the block to fail. My tests were all examples with a single expression. For now you can fix it by breaking it into two blocks.

tpolecat avatar Jul 12 '15 17:07 tpolecat

I see there's a :paste option, could that be combined with :fail to, in essence, get the desired result? If so, can close issue.

wheaties avatar Dec 20 '16 20:12 wheaties

Yes, good point. I think so, but let's leave this open for now.

tpolecat avatar Dec 20 '16 20:12 tpolecat

To be clear there is not yet a :paste option.

tpolecat avatar Dec 21 '16 00:12 tpolecat