Skip to content

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

Closed
catap opened this issue May 17, 2021 · 11 comments
Closed

Comments

@catap
Copy link

catap commented May 17, 2021

After migrating a code base to scala.js 1.5.1 and scala3 compileIncremental phase fails with error:

error] java.lang.IllegalArgumentException: Invalid name: [-3, 3]$2
[error] 	at org.scalajs.ir.Names$.org$scalajs$ir$Names$$$throwInvalidEncodedName(Names.scala:536)
[error] 	at org.scalajs.ir.Names$.org$scalajs$ir$Names$$$validateSimpleEncodedName(Names.scala:550)
[error] 	at org.scalajs.ir.Names$.org$scalajs$ir$Names$$$validateSimpleEncodedName(Names.scala:539)
[error] 	at org.scalajs.ir.Names$LocalName$.apply(Names.scala:106)
[error] 	at org.scalajs.ir.Names$LocalName$.apply(Names.scala:109)
[error] 	at dotty.tools.backend.sjs.JSEncoding$LocalNameGenerator.freshLocalIdent(JSEncoding.scala:109)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.freshLocalIdent(JSCodeGen.scala:132)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.$anonfun$29(JSCodeGen.scala:3044)
[error] 	at scala.collection.immutable.List.map(List.scala:250)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genClosure(JSCodeGen.scala:3051)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1532)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1469)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genExpr(JSCodeGen.scala:1263)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genActualArgs$$anonfun$1(JSCodeGen.scala:3679)
[error] 	at scala.collection.immutable.List.map(List.scala:250)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genActualArgs(JSCodeGen.scala:3679)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genNormalApply(JSCodeGen.scala:2635)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genApply(JSCodeGen.scala:1722)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1390)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1469)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1469)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1469)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1469)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStat(JSCodeGen.scala:1241)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr$$anonfun$5(JSCodeGen.scala:1469)
[error] 	at scala.collection.immutable.List.map(List.scala:246)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1469)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genStat(JSCodeGen.scala:1241)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genBody$1(JSCodeGen.scala:1145)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genMethodDef(JSCodeGen.scala:1151)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genMethodWithCurrentLocalNameScope$$anonfun$1(JSCodeGen.scala:1118)
[error] 	at dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:35)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genMethodWithCurrentLocalNameScope(JSCodeGen.scala:1124)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genMethod$$anonfun$1(JSCodeGen.scala:1022)
[error] 	at dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:35)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genMethod(JSCodeGen.scala:1023)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genScalaClass$$anonfun$2(JSCodeGen.scala:341)
[error] 	at scala.collection.immutable.List.foreach(List.scala:333)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genScalaClass(JSCodeGen.scala:346)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit$$anonfun$6$$anonfun$1(JSCodeGen.scala:217)
[error] 	at dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:35)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit$$anonfun$2(JSCodeGen.scala:221)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.immutable.List.foreach(List.scala:333)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit(JSCodeGen.scala:223)
[error] 	at dotty.tools.backend.sjs.JSCodeGen.run(JSCodeGen.scala:152)
[error] 	at dotty.tools.backend.sjs.GenSJSIR.run(GenSJSIR.scala:15)
[error] 	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303)
[error] 	at scala.collection.immutable.List.map(List.scala:250)
[error] 	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
[error] 	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] 	at dotty.tools.dotc.Run.runPhases$5(Run.scala:215)
[error] 	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:223)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] 	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] 	at dotty.tools.dotc.Run.compileUnits(Run.scala:230)
[error] 	at dotty.tools.dotc.Run.compileSources(Run.scala:166)
[error] 	at dotty.tools.dotc.Run.compile(Run.scala:150)
[error] 	at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] 	at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] 	at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] 	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:186)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157)
[error] 	at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] 	at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:174)
[error] 	at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:172)
[error] 	at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:457)
[error] 	at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] 	at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] 	at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] 	at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
[error] 	at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:412)
[error] 	at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
[error] 	at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:399)
[error] 	at sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] 	at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2346)
[error] 	at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2303)
[error] 	at sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] 	at sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] 	at sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] 	at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] 	at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2299)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)

Unfortently I have no idea how to make minimised version.

@smarter
Copy link
Member

smarter commented May 17, 2021

Even if you can't minimize it, can you provide a link to a git branch where the problem is reproducible?
In any case, could you try adding scalacOptions += "-Ycheck:all" to your project and compiling again? This might give us a more informative stacktrace.

@catap
Copy link
Author

catap commented May 17, 2021

@smarter unfortunately I can't shared the code :(

But I definitely can recompile it with -Ycheck:all. Here the new log:

[error] java.lang.AssertionError: assertion failed: non member selection of method asInstanceOf in class Object from (ev$1 : ErasedValueType(scala.scalajs.js.UndefOrOps, Object)) in ev$1.asInstanceOf
[error] 	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] 	at dotty.tools.dotc.transform.FirstTransform.checkPostCondition(FirstTransform.scala:59)
[error] 	at dotty.tools.dotc.transform.TreeChecker.dotty$tools$dotc$transform$TreeChecker$Checker$$_$typedUnadapted$$anonfun$1(TreeChecker.scala:341)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.immutable.List.foreach(List.scala:333)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:341)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] 	at dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:1073)
[error] 	at dotty.tools.dotc.typer.Applications.typedTypeApply$(Applications.scala:303)
[error] 	at dotty.tools.dotc.typer.Typer.typedTypeApply(Typer.scala:103)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2688)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$2(ProtoTypes.scala:414)
[error] 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:370)
[error] 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:415)
[error] 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:836)
[error] 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:836)
[error] 	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:530)
[error] 	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:595)
[error] 	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:433)
[error] 	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:721)
[error] 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:835)
[error] 	at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1046)
[error] 	at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:303)
[error] 	at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:103)
[error] 	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:893)
[error] 	at dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:972)
[error] 	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2924)
[error] 	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:983)
[error] 	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1021)
[error] 	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:303)
[error] 	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:103)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2669)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1018)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$2$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withBlock(TreeChecker.scala:218)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2677)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:62)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2674)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] 	at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:2078)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2643)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2822)
[error] 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:524)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1012)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1016)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$2$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withBlock(TreeChecker.scala:218)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2677)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedLabeled(Typer.scala:1613)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedLabeled$$anonfun$1(TreeChecker.scala:529)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedLabeled(TreeChecker.scala:529)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2662)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] 	at dotty.tools.dotc.typer.Typer.$anonfun$34(Typer.scala:2142)
[error] 	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
[error] 	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2142)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$1(TreeChecker.scala:481)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef(TreeChecker.scala:484)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2646)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2822)
[error] 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:524)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1012)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1016)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$2$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withBlock(TreeChecker.scala:218)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2677)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$2(ProtoTypes.scala:414)
[error] 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:370)
[error] 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:415)
[error] 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:836)
[error] 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:836)
[error] 	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:530)
[error] 	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:595)
[error] 	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:595)
[error] 	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:433)
[error] 	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:721)
[error] 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:835)
[error] 	at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1046)
[error] 	at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:303)
[error] 	at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:103)
[error] 	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:893)
[error] 	at dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:972)
[error] 	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2924)
[error] 	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:983)
[error] 	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1021)
[error] 	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:303)
[error] 	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:103)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2669)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2849)
[error] 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:524)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1012)
[error] 	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1016)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$2$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$1(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withBlock(TreeChecker.scala:218)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:506)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2677)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] 	at dotty.tools.dotc.typer.Typer.$anonfun$34(Typer.scala:2142)
[error] 	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
[error] 	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2142)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$1(TreeChecker.scala:481)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:190)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef(TreeChecker.scala:484)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2646)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2822)
[error] 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:524)
[error] 	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2328)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:459)
[error] 	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2657)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2661)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2730)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2822)
[error] 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2872)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:524)
[error] 	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2451)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedPackageDef(TreeChecker.scala:550)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2702)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2731)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:324)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2796)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2800)
[error] 	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:308)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2916)
[error] 	at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:142)
[error] 	at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:111)
[error] 	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303)
[error] 	at scala.collection.immutable.List.map(List.scala:250)
[error] 	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
[error] 	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] 	at dotty.tools.dotc.Run.runPhases$5(Run.scala:215)
[error] 	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:223)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] 	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] 	at dotty.tools.dotc.Run.compileUnits(Run.scala:230)
[error] 	at dotty.tools.dotc.Run.compileSources(Run.scala:166)
[error] 	at dotty.tools.dotc.Run.compile(Run.scala:150)
[error] 	at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] 	at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] 	at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] 	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:186)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157)
[error] 	at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157)
[error] 	at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] 	at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:174)
[error] 	at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:172)
[error] 	at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:457)
[error] 	at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] 	at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] 	at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] 	at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
[error] 	at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:412)
[error] 	at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
[error] 	at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:399)
[error] 	at sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] 	at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] 	at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2346)
[error] 	at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2303)
[error] 	at sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] 	at sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] 	at sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] 	at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] 	at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2299)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)

@smarter
Copy link
Member

smarter commented May 17, 2021

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 ???, then delete stuff and see if the problem still arises, rinse and repeat.

@catap
Copy link
Author

catap commented May 17, 2021

@smarter is it possible to run somehow scalac for scala.js from cli for specified file?

nevermind, I'll do it via sbt

@catap
Copy link
Author

catap commented May 18, 2021

@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 fullLinkJS works near a minute.

@smarter
Copy link
Member

smarter commented May 18, 2021

Maybe the issue is specific to incremental compilation? Does it happen when you do "clean; compile" in sbt?

@catap
Copy link
Author

catap commented May 18, 2021

@smarter I've run clean each time :(

@catap
Copy link
Author

catap commented May 18, 2021

@smarter so, [-3, 3] is a real name of variable. After figure it out I can create a simple reproducer of this issue:

import org.scalatest._
import org.scalatest.matchers.should

class MinimizedTest extends wordspec.AnyWordSpec with should.Matchers {
  "level1" when {
    val `[-3, 3]` = 1
      "level2" in {
        val name = 1 + 2
        name shouldBe `[-3, 3]`
      }
  }
}

I've used:

  • scala 3.0.0
  • scala.js 1.5.1
  • scalatest 3.2.9

And as soon as I renamed [-3, 3] to something else => it works.

@smarter
Copy link
Member

smarter commented May 18, 2021

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 smarter changed the title compileIncremental fails Scala.js backend fails with "Invalid name" for closure parameter name containing "[" May 18, 2021
@catap
Copy link
Author

catap commented May 18, 2021

@smarter FYI this code works fine for 2.11, 2.12 and 2.13 at scala.js.

@sjrd
Copy link
Member

sjrd commented May 18, 2021

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?

smarter added a commit that referenced this issue May 19, 2021
…-closure

Fix #12507: Scala.js: Mangle param names in closures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants