Skip to content

REPL crashes when using :type or :doc command without any parameter #9538

Closed
@JackyWangMislantiaJnirvana

Description

Minimized code

scala> :type
// or
scala> :doc

Output (click arrow to expand)

REPL crashes after executing such line

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
	at dotty.tools.dotc.util.SourceFile.lineToOffset(SourceFile.scala:124)
	at dotty.tools.dotc.util.SourcePosition.lineOffsets$$anonfun$1(SourcePosition.scala:40)
	at dotty.runtime.function.JFunction1$mcII$sp.apply(JFunction1$mcII$sp.java:12)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.util.SourcePosition.lineOffsets(SourcePosition.scala:40)
	at dotty.tools.dotc.util.SourcePosition.beforeAndAfterPoint(SourcePosition.scala:43)
	at dotty.tools.dotc.reporting.MessageRendering.sourceLines(MessageRendering.scala:71)
	at dotty.tools.dotc.reporting.MessageRendering.sourceLines$(MessageRendering.scala:18)
	at dotty.tools.repl.Rendering$$anon$1.sourceLines(Rendering.scala:35)
	at dotty.tools.dotc.reporting.MessageRendering.messageAndPos(MessageRendering.scala:152)
	at dotty.tools.dotc.reporting.MessageRendering.messageAndPos$(MessageRendering.scala:18)
	at dotty.tools.repl.Rendering$$anon$1.messageAndPos(Rendering.scala:35)
	at dotty.tools.repl.Rendering.formatError$$anonfun$1(Rendering.scala:100)
	at dotty.tools.dotc.reporting.NoExplanation.msg(Message.scala:120)
	at dotty.tools.dotc.reporting.NoExplanation.toString(Message.scala:124)
	at java.lang.String.valueOf(String.java:2994)
	at java.io.PrintStream.println(PrintStream.java:821)
	at dotty.tools.repl.ReplDriver.displayErrors$$anonfun$3(ReplDriver.scala:399)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at dotty.tools.repl.ReplDriver.displayErrors(ReplDriver.scala:399)
	at dotty.tools.repl.ReplDriver.interpretCommand$$anonfun$2(ReplDriver.scala:380)
	at scala.util.Either.fold(Either.scala:190)
	at dotty.tools.repl.ReplDriver.interpretCommand(ReplDriver.scala:381)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:203)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:129)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:132)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:151)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:132)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions