-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scala.js backend fails with "Invalid name" for closure parameter name containing "[" #12507
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
Comments
Even if you can't minimize it, can you provide a link to a git branch where the problem is reproducible? |
@smarter unfortunately I can't shared the code :( But I definitely can recompile it with
|
That looks unrelated, I'm afraid without a minimization there's not much we can do here. If you can't easily delete files and still reproduce the problem, a good way to minimize things is to start by replacing method bodies by |
nevermind, I'll do it via sbt |
@smarter because this happened on compiling unit tests => I've removed all tests and start to revert one by one. It seems that an issue appears not at some code, but at codebase it self. I mean, as soon as I reverted enough tests => it fails such way. If I removed all added tests, and just add a test that fails last time => works fine. And started to add another tests which was missed which includes a test hat fails last time => also fine. But after I've reverted more tests => it is filed. Any suggestion how can I debug it future? And yes, code base is big plus it is used scalatest what also isn't trivial and compiling on modern hardware requires something like a few minutes — for example |
Maybe the issue is specific to incremental compilation? Does it happen when you do "clean; compile" in sbt? |
@smarter I've run |
@smarter so,
I've used:
And as soon as I renamed |
Oh, great! I was able to further minimize this to: object Test {
def foo(`[-3, 3]`: Int): Int => Int = {
x => `[-3, 3]`
}
} Which crashes with scala.js but not with the jvm backend. On the JVM side the parameter name gets manged in the backend: https://github.com/lampepfl/dotty/blob/4bf2f0476298edd1feff4c52e1e4a6c54b0b79a4/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala#L344 (just like scala 2: https://github.com/scala/scala/blob/8490d3711e39149cbb3b13bd6ff6335a4378b77c/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala#L638), but on the scala.js side it seems the backend is expecting parameter names to be valid JVM names at this point. @sjrd can this restriction be relaxed? |
@smarter FYI this code works fine for 2.11, 2.12 and 2.13 at scala.js. |
I'll have a look. I'm surprised this is different in 3 than in 2.x, because I don't remember adding any specific code in 2.x that mangles the JVM invalid characters. Perhaps in 2.x this mangling is done earlier in the compiler pipeline? |
…-closure Fix #12507: Scala.js: Mangle param names in closures.
After migrating a code base to scala.js 1.5.1 and scala3
compileIncremental
phase fails with error:Unfortently I have no idea how to make minimised version.
The text was updated successfully, but these errors were encountered: