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

New compilation failure when for-loop and match both used in async (after upgrading 0.9.5→0.9.7) #56

Closed
ScoreUnder opened this issue Jan 31, 2022 · 5 comments

Comments

@ScoreUnder
Copy link

I found a compile-time error in my project which I bisected to one of these commits in dotty-cps-async:

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
a74c5d9
afa62ed
2e7794c
dd3ddf9
070ac89
2f744f2
b3d9feb
We cannot bisect more!

I had to skip some which either would not build on my machine or which did not run in my project for other reasons (class version mismatch).

I have tried to minimise the code which triggers the bug, but here are a few pieces of code that all trigger it:

Import statements
import cps.*
import cps.monads.FutureAsyncMonad
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
    def thing(): Future[String] =
      async {
        for _ <- Nil do
          ???

        Option("") match
          case None =>
          case Some(_) =>
            await(??? : Future[Unit])

        "Test"
      }
    def thing(): Future[String] =
      async {
        for _ <- Nil do
          ???

        Option("") match
          case None =>
            await(??? : Future[String])
          case Some(_) =>
            await(??? : Future[String])
      }
    def thing(): Future[String] =
      async {
        for _ <- Nil do
          ???

        await({
          Option("") match
            case None =>
              ??? : Future[String]
            case Some(_) =>
              ??? : Future[String]
        })
      }

(Pick whichever is the simpler example for your internals)

Notably, removing the foreach-loop (which is not using await) somehow makes it work again, as does collapsing the match. In the 3rd example, if you extract the argument to await into a variable and await on the variable instead, that works too.

@ScoreUnder
Copy link
Author

real-life code where I worked around it: ScoreUnder/canti-bot@a92a67c

@ScoreUnder ScoreUnder changed the title New compilation failure when for-loop and match both used in async New compilation failure when for-loop and match both used in async (after upgrading 0.9.5→0.9.7) Jan 31, 2022
@rssh
Copy link
Owner

rssh commented Jan 31, 2022

Hi, thanks - will look.
It's with 0.9.8 and dotty-3.1.1 ?

@rssh
Copy link
Owner

rssh commented Jan 31, 2022

caused by scala/scala3#14393

@ScoreUnder
Copy link
Author

It's with 0.9.8 and dotty-3.1.1 ?

It's with 0.9.7 and dotty 3.1.1. The issue still does happen on the latest master too (d82a36a).

Thanks for looking into this

@rssh
Copy link
Owner

rssh commented Feb 1, 2022

should be fixed now.

@rssh rssh closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants