Compiler version
3.8.1, 3.8.2
Minimized code
Scastie
import scala.scalajs.js
// Does not compile in Scala 3.8.x, but does compile in Scala 2.13.8
js.async(
js.await(js.Promise.resolve[Unit](()))
)
// Compiles in both Scala 3.8.x and 2.13.8
js.async(
js.await(js.Promise.resolve[Int](5))
)
Output
js.await(js.Promise.resolve[Unit](()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Illegal use of js.await().
It can only be used inside a js.async {...} block, without any lambda,
by-name argument or nested method in-between.
If you compile for WebAssembly, you can allow arbitrary js.await()
calls by adding the following import:
import scala.scalajs.js.wasm.JSPI.allowOrphanJSAwait
Expectation
Consistent behaviour between Scala 2 and Scala 3 when using js.async/js.await.
Potentially related PRs:
Compiler version
3.8.1, 3.8.2
Minimized code
Scastie
Output
Expectation
Consistent behaviour between Scala 2 and Scala 3 when using
js.async/js.await.Potentially related PRs:
js.async { ... js.await(p) ... }, and support JSPI on WebAssembly. scala-js/scala-js#5130