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

REPL crashes when trying to delete match operand in longer statement #13620

Closed
BarkingBad opened this issue Sep 27, 2021 · 1 comment · Fixed by #13640
Closed

REPL crashes when trying to delete match operand in longer statement #13620

BarkingBad opened this issue Sep 27, 2021 · 1 comment · Fixed by #13640

Comments

@BarkingBad
Copy link
Contributor

Compiler version

3.1.0-RC1

Minimized code

Paste/Type into the REPL following code:

def calculateSum(i: List[Int]): Int =
     i match
         case Nil => 0
         case head :: tail => head + calculateSum(tail)

Now try to move the cursor to i before match and try to remove it using backspace.

Output

Scala REPL crashes with the following stacktrace

     |      iException in thread "main" java.lang.AssertionError: assertion failed
     |  at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
     |  at dotty.tools.dotc.util.Spans$Span$.start$extension(Spans.scala:44)
	at dotty.tools.dotc.parsing.Parsers$Parser.matchClause(Parsers.scala:2114)
	at dotty.tools.dotc.parsing.Parsers$Parser.recur$4(Parsers.scala:955)
	at dotty.tools.dotc.parsing.Parsers$Parser.infixOps(Parsers.scala:964)
	at dotty.tools.dotc.parsing.Parsers$Parser.postfixExprRest(Parsers.scala:2209)
	at dotty.tools.dotc.parsing.Parsers$Parser.postfixExpr(Parsers.scala:2199)
	at dotty.tools.dotc.parsing.Parsers$Parser.expr1(Parsers.scala:2044)
	at dotty.tools.dotc.parsing.Parsers$Parser.expr(Parsers.scala:1937)
	at dotty.tools.dotc.parsing.Parsers$Parser.$init$$$anonfun$5(Parsers.scala:1903)
	at dotty.tools.dotc.parsing.Parsers$Parser.subPart(Parsers.scala:600)
	at dotty.tools.dotc.parsing.Parsers$Parser.subExpr(Parsers.scala:1905)
	at dotty.tools.dotc.parsing.Parsers$Parser.defDefOrDcl(Parsers.scala:3358)
	at dotty.tools.dotc.parsing.Parsers$Parser.defOrDcl(Parsers.scala:3249)
	at dotty.tools.dotc.parsing.Parsers$Parser.localDef(Parsers.scala:3930)
	at dotty.tools.dotc.parsing.Parsers$Parser.blockStatSeq$$anonfun$1(Parsers.scala:3954)
	at dotty.tools.dotc.parsing.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:477)
	at dotty.tools.dotc.parsing.Parsers$Parser.blockStatSeq(Parsers.scala:3960)
	at dotty.tools.dotc.printing.SyntaxHighlighting$.highlight(SyntaxHighlighting.scala:124)
	at dotty.tools.repl.JLineTerminal$Highlighter.highlight(JLineTerminal.scala:80)
	at org.jline.reader.impl.LineReaderImpl.getHighlightedBuffer(LineReaderImpl.java:4071)
	at org.jline.reader.impl.LineReaderImpl.getDisplayedBufferWithPrompts(LineReaderImpl.java:4010)
	at org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3879)
	at org.jline.reader.impl.LineReaderImpl.doCleanup(LineReaderImpl.java:2566)
	at org.jline.reader.impl.LineReaderImpl.cleanup(LineReaderImpl.java:2557)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:727)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:468)
	at dotty.tools.repl.JLineTerminal.readLine(JLineTerminal.scala:72)
	at dotty.tools.repl.ReplDriver.readLine$1(ReplDriver.scala:140)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:150)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:155)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:174)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:155)
	at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:117)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:137)
	at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:175)
	at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at coursier.bootstrap.launcher.a.a(Unknown Source)
	at coursier.bootstrap.launcher.Launcher.main(Unknown Source)

error

Expectation

I can remove the i and the REPL waits for my final input.

@BarkingBad
Copy link
Contributor Author

The issue seems to be when there is no identifier before match. If we have a name like list, we can remove any characters as long as one character will exist. After removing the last character, the REPL crashes.

@SethTisue SethTisue changed the title REPL craches when trying to delete match operand in longer statement REPL crashes when trying to delete match operand in longer statement Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant