Skip to content

REPL crashing on standalone _root_ reference #17757

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
prolativ opened this issue Jun 2, 2023 · 2 comments · Fixed by #18187
Closed

REPL crashing on standalone _root_ reference #17757

prolativ opened this issue Jun 2, 2023 · 2 comments · Fixed by #18187
Labels
Milestone

Comments

@prolativ
Copy link
Contributor

prolativ commented Jun 2, 2023

Compiler version

3.3.2-RC1-bin-20230601-8814760-NIGHTLY - prints compiler stack trace, keeps REPL alive
3.3.1-RC1 - prints compiler stack trace, keeps REPL alive
3.3.0 - crashes REPL

Minimized code

scala> _root_

Output (click arrow to expand)

Warning: mocking up superclass for module class <root>
java.lang.AssertionError: assertion failed: Cannot create ClassBType from NoSymbol
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.backend.jvm.BTypesFromSymbols.classBTypeFromSymbol(BTypesFromSymbols.scala:51)
	at dotty.tools.backend.jvm.BTypesFromSymbols.buildNestedInfo(BTypesFromSymbols.scala:218)
	at dotty.tools.backend.jvm.BTypesFromSymbols.setClassInfo(BTypesFromSymbols.scala:176)
	at dotty.tools.backend.jvm.BTypesFromSymbols.classBTypeFromSymbol$$anonfun$1(BTypesFromSymbols.scala:64)
	at scala.collection.mutable.HashMap.getOrElse(HashMap.scala:436)
	at dotty.tools.backend.jvm.BTypesFromSymbols.classBTypeFromSymbol(BTypesFromSymbols.scala:65)
	at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.getClassBType(BCodeHelpers.scala:177)
	at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.getClassBType$(BCodeHelpers.scala:129)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.getClassBType(BCodeSkelBuilder.scala:74)
	at dotty.tools.backend.jvm.BCodeHelpers.primitiveOrClassToBType$1$$anonfun$1(BCodeHelpers.scala:714)
	at scala.collection.immutable.HashMap.getOrElse(HashMap.scala:683)
	at dotty.tools.backend.jvm.BCodeHelpers.primitiveOrClassToBType$1(BCodeHelpers.scala:714)
	at dotty.tools.backend.jvm.BCodeHelpers.dotty$tools$backend$jvm$BCodeHelpers$$typeToTypeKind(BCodeHelpers.scala:733)
	at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.toTypeKind(BCodeHelpers.scala:201)
	at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.toTypeKind$(BCodeHelpers.scala:129)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.toTypeKind(BCodeSkelBuilder.scala:74)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.symInfoTK(BCodeSkelBuilder.scala:103)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.addClassFields$$anonfun$2(BCodeSkelBuilder.scala:352)
	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:333)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.addClassFields(BCodeSkelBuilder.scala:358)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:232)
	at dotty.tools.backend.jvm.CodeGen.genClass(CodeGen.scala:138)
	at dotty.tools.backend.jvm.CodeGen.genClassDef$1(CodeGen.scala:55)
	at dotty.tools.backend.jvm.CodeGen.genClassDefs$1(CodeGen.scala:101)
	at dotty.tools.backend.jvm.CodeGen.genClassDefs$1$$anonfun$1(CodeGen.scala:99)
	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:333)
	at dotty.tools.backend.jvm.CodeGen.genClassDefs$1(CodeGen.scala:99)
	at dotty.tools.backend.jvm.CodeGen.genUnit(CodeGen.scala:104)
	at dotty.tools.backend.jvm.GenBCode.run(GenBCode.scala:76)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:327)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:331)
	at dotty.tools.backend.jvm.GenBCode.runOn(GenBCode.scala:87)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246)
	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:1321)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:262)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:270)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:279)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:279)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:200)
	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:87)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:307)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:269)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:169)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:172)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:211)
	at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:185)
	at dotty.tools.runner.ScalaClassLoader$.asContext(ScalaClassLoader.scala:80)
	at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:185)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:172)
	at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:134)
	at dotty.tools.repl.Main$.main(Main.scala:7)
	at dotty.tools.repl.Main.main(Main.scala)
Error while emitting rs$line$1
assertion failed: Cannot create ClassBType from NoSymbol
1 error foun

Also code completions on _root_.<TAB> in REPL don't work

@mbovel mbovel added the Spree Suitable for a future Spree label Jun 13, 2023
@scala-center-bot
Copy link

This issue was picked for the Issue Spree No. 32 of 20 June 2023 which takes place in 7 days. @Linyxus, @nmcb, @jan-pieter, @TheElectronWill will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

@som-snytt
Copy link
Contributor

Did someone laugh because the message says, "mocking"?

Also compare

Welcome to Scala 3.3.0 (20.0.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> val _root_ = ""
val _root_: String = ""

scala> _root_.length
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |_root_.length
  |^^^^^^^^^^^^^
  |value length is not a member of <root>
1 error found

and

Welcome to Scala 2.13.11 (OpenJDK 64-Bit Server VM, Java 20.0.1).
Type in expressions for evaluation. Or try :help.

scala> val _root_ = ""
val _root_: String = ""

scala> _root_.length
              ^
       error: object length is not a member of package <root>
       ^
       warning: _root_ in root position of qualifier refers to the root package, not value _root_, which is in scope

scala> _root_
       ^
       error: reference to _root_ is ambiguous;
       it is both defined in <none> and imported subsequently by
       import _root_

smarter added a commit that referenced this issue Jul 14, 2023
References #18020, didn't actually fix that, because it addressed
aspects of using `_root_` in definitions. Adding more details to that
ticket.
Fixes #17757
Fixes #18050
Includes the code in scala/bug#12508
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants