title: Getting compilation error when using for and yield
body: <p>What is wrong with the following code snippet? </p>
  
  <pre><code>val loginInfoFuture: Future[LoginInfo] = credentialsProvider.authenticate(credentials)
                for{loginInfo &lt;- loginInfoFuture}{ 
                  println("in loginInfo future")
                } yield  Future{Ok(Json.toJson(JsonResultError("Invalid Body Type. Need Json")))}
  </code></pre>
  
  <p>I am seeing error in IDE - <code>Error:(239, 17) ';' expected but 'yield' found.
                } yield  Ok(Json.toJson(JsonResultError("Invalid Body Type. Need Json")))</code></p>
  
  <p>I tried a similar piece of code on REPL and that seem to work fine.</p>
  
  <pre><code>scala&gt; import scala.concurrent.Future
  import scala.concurrent.Future
  
  scala&gt; import scala.concurrent.ExecutionContext.Implicits.global
  import scala.concurrent.ExecutionContext.Implicits.global
  
  scala&gt; val f:Future[Int] = Future{1}
  f: scala.concurrent.Future[Int] = Future(Success(1))
  
  scala&gt; for(f1 &lt;- f) yield f1
  res0: scala.concurrent.Future[Int] = Future(&lt;not completed&gt;)
  
  scala&gt;
  </code></pre>
  
  <p>For reference, below is the full function</p>
  
  <pre><code>  def signInUser = silhouette.UserAwareAction.async { implicit request =&gt; { 
  
  val body: AnyContent = request.body
  val jsonBody: Option[JsValue] = body.asJson
  
  jsonBody match {
    case Some(json) =&gt; {
  
      val userSignin: Option[UserSignin] = json.asOpt[UserSignin] //check if json conforms with UserProfile structure
      userSignin match {
          case Some(signinInfo) =&gt; { //format of JSON is correct
            //Get signin info from JSON (email and password)
            val credentials: Credentials = Credentials(signinInfo.signinInfo.email, signinInfo.signinInfo.password)
  
            val authInfoRepository = new DelegableAuthInfoRepository(userRepo.passwordRepo)
            val passwordHasherRegistory = new PasswordHasherRegistry(userRepo.passwordHasher)
            val credentialsProvider = new CredentialsProvider(authInfoRepository, passwordHasherRegistory)
  
  
            for{loginInfo &lt;- loginInfoFuture}{ //for returns unit. Should use yield
              println("in loginInfo future")
            } yield  Future{Ok(Json.toJson(JsonResultError("Invalid Body Type. Need Json")))}
  
          }
          case None =&gt; { //No signin info found
            Future {
              Ok(Json.toJson(JsonResultError("Invalid user. No Login info found")))
            }
          }
        }
      }
    case None =&gt; {//NO Body
       Future {
                Ok(Json.toJson(JsonResultError("Invalid Body Type. Need Json")))
              } 
    }
  } //jsonBody match
  </code></pre>
  
  <p>}//async
  }//def signin</p>