Skip to content
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

Dotty crashing when using a loop variable in an enum in a loop local class #21931

Open
Sparkaar opened this issue Nov 12, 2024 · 1 comment
Open

Comments

@Sparkaar
Copy link

Compiler version

Scala compiler version 3.5.2 -- Copyright 2002-2024, LAMP/EPFL
Scala compiler version 3.6.0-RC1-bin-SNAPSHOT-git-18af52a -- Copyright 2002-2024, LAMP/EPFL

Minimized code

object bla{
  for ( NotFound: Char<- (List('a'))) {class crashing{
    enum issue{
    NotFound
  case obligatory
    }
  }
  ;64.asInstanceOf[Char]}
}

Output (click arrow to expand)

-- Warning: bla.scala:2:16 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 |  for ( NotFound: Char<- (List('a'))) {class crashing{
  |                ^
  |                Type ascriptions after patterns other than:
  |                  * variable pattern, e.g. `case x: String =>`
  |                  * number literal pattern, e.g. `case 10.5: Double =>`
  |                are no longer supported. Remove the type ascription or move it to a separate variable pattern.
-- [E129] Potential Issue Warning: bla.scala:4:4 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 |    NotFound 
  |    ^^^^^^^^
  |    A pure expression does nothing in statement position
  |
  | longer explanation available when compiling with `-explain`

  unhandled exception while running MegaPhase{lambdaLift, elimStaticThis, countOuterAccesses} on bla.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.

     while compiling: bla.scala
        during phase: MegaPhase{lambdaLift, elimStaticThis, countOuterAccesses}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.2
            settings: 

Exception in thread "main" java.lang.IllegalArgumentException: Could not find proxy for NotFound: Char in [parameter NotFound, method $anonfun, constructor bla, object bla, package <empty>, package <root>], encl = constructor $anon, owners = constructor $anon, anonymous class crashing.this.issue with scala.runtime.EnumValue with scala.deriving.Mirror.Singleton {...}, method $new, object issue, class crashing, method $anonfun, constructor bla, object bla, package <empty>, package <root>; enclosures = constructor $anon, anonymous class crashing.this.issue with scala.runtime.EnumValue with scala.deriving.Mirror.Singleton {...}, package <empty>, package <root>
	at dotty.tools.dotc.transform.LambdaLift$Lifter.searchIn$1(LambdaLift.scala:137)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.proxy(LambdaLift.scala:150)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.proxyRef(LambdaLift.scala:168)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.addFreeArgs$$anonfun$1(LambdaLift.scala:174)
	at scala.collection.immutable.List.map(List.scala:247)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.addFreeArgs(LambdaLift.scala:174)
	at dotty.tools.dotc.transform.LambdaLift.transformApply(LambdaLift.scala:312)
	at dotty.tools.dotc.transform.LambdaLift.transformApply(LambdaLift.scala:311)
	at dotty.tools.dotc.transform.MegaPhase.goApply(MegaPhase.scala:681)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:297)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.loop$2(MegaPhase.scala:471)
	at dotty.tools.dotc.transform.MegaPhase.transformBlock(MegaPhase.scala:476)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:315)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:265)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.transformSpecificTree(MegaPhase.scala:461)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:373)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.loop$2(MegaPhase.scala:471)
	at dotty.tools.dotc.transform.MegaPhase.transformBlock(MegaPhase.scala:476)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:315)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:265)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:376)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:376)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.loop$2(MegaPhase.scala:471)
	at dotty.tools.dotc.transform.MegaPhase.transformBlock(MegaPhase.scala:476)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:315)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:265)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.loop$2(MegaPhase.scala:471)
	at dotty.tools.dotc.transform.MegaPhase.transformBlock(MegaPhase.scala:476)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:315)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.loop$3(MegaPhase.scala:486)
	at dotty.tools.dotc.transform.MegaPhase.transformTrees(MegaPhase.scala:486)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:296)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.loop$2(MegaPhase.scala:471)
	at dotty.tools.dotc.transform.MegaPhase.transformBlock(MegaPhase.scala:476)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:315)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:265)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.transformSpecificTree(MegaPhase.scala:461)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:373)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
	at dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
	at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:399)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
	at dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:481)
	at dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:493)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:380)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:373)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
	at dotty.tools.dotc.Run.compileSources(Run.scala:282)
	at dotty.tools.dotc.Run.compile(Run.scala:267)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
	at dotty.tools.dotc.Driver.process(Driver.scala:201)
	at dotty.tools.dotc.Driver.process(Driver.scala:169)
	at dotty.tools.dotc.Driver.process(Driver.scala:181)
	at dotty.tools.dotc.Driver.main(Driver.scala:211)
	at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
	at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
	at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)
@Sparkaar Sparkaar added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 12, 2024
@Gedochao
Copy link
Contributor

A slightly more readable version of the reproduction:

object bla {
  for (NotFound: Char <- (List('a'))) {
    class crashing {
      enum issue {
        NotFound
        case obligatory
      }
    }; 64.asInstanceOf[Char]
  }
}

@Gedochao Gedochao added area:transform area:enums and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 12, 2024
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

2 participants