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
Variable named await
emitted in ESModule mode
#4705
Comments
Does it actually fail to parse? |
It seems to be reserved in modules, indeed: |
By the browser, I think it works, but stricter minifiers like swc-project/swc#5359 apparently don't like it. |
There are two aspects to fixing this issue. First, we should mangle any identifier that happens to be named scala-js/linker/shared/src/main/scala/org/scalajs/linker/backend/emitter/NameGen.scala Lines 350 to 372 in 722d724
and similarly at scala-js/linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala Lines 5948 to 5964 in 722d724
That is fine, as it is only a codegen change that does not affect semantics. The other thing is problematic: we must also forbid to use scala-js/ir/shared/src/main/scala/org/scalajs/ir/Trees.scala Lines 854 to 875 in 722d724
which is tested at scala-js/compiler/src/test/scala/org/scalajs/nscplugin/test/JSGlobalScopeTest.scala Lines 329 to 338 in 722d724
but doing so is an incompatible change! There could be codebases that already use await as a global ref. Either when emitting a NoModule or CommonJSModule, for which it is valid, or even when emitting an ESModule, since apparently browsers don't actually complain.
I am not sure what is the best course of action for the global refs. My best idea so far is to only warn about them at compile time (not link time), saying that they may cause downstream |
Fix #4705: Avoid emitting identifiers called 'await'.
So this code translated to javascript https://github.com/typelevel/cats-effect/blob/series/3.x/kernel/shared/src/main/scala/cats/effect/kernel/GenConcurrent.scala#L74-L81 features something like
Shouldn't we escape that name? Since I think in strict mode its a reserved word?
The text was updated successfully, but these errors were encountered: