question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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: a74c5d997806a37d164cfd0a9d8da9f4f1dbe522 afa62ed96da96b0b7619165bee4d64abc052f2b4 2e7794c0d10aa54ff4ad3c8563e999020873ab1e dd3ddf950b20138a0f845a2ba571fc6ccdfe06ce 070ac891bb87d0f767065ed65dfaf94dbe0fc1f0 2f744f2b73003d3d819c5a93bfc622c5f6e9a05d b3d9feb2a2e9c2305e2f65d0a55a9f22753d5c46 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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rsshcommented, Feb 1, 2022

should be fixed now.

0reactions
ScoreUndercommented, Jan 31, 2022

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 (d82a36a5fce247eeeb6658cd92112f649f0825c9).

Thanks for looking into this

Read more comments on GitHub >

github_iconTop Results From Across the Web

esbuild/CHANGELOG-2021.md at main - GitHub
This release includes a warning for people that try to use both CommonJS and ES module export styles in the same file. Here's...
Read more >
Async and Await with For Loop [duplicate] - Stack Overflow
The issue is that the first LoadAsync waits for the job to finish before giving control back to the loop instead of allowing...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
when side tabs are on, clicking on a new tab and clicking on the red X to close a tab are both slow...
Read more >
JavaScript async and await in loops - freeCodeCamp
We are going to loop through this array. const forLoop = async _ => { console.log(“Start”); for (let index = 0; index <...
Read more >
c20b69951c5ad0b1f02410850c...
Allow extending of raid LVs created with --nosync after a failed repair. - Merge adjacent segments when pvmove is finished. - Ensure very...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found