Skip to content

AssertionError during parsing #25716

Description

@SolalPirelli

Compiler version

3.8.3-RC3

Minimized code

The following piece of code crashes the REPL:

object Fuzz {
def f(x: Int): Unit =
  println(x)
@inline def g[@inline x: _](y: x): Unit =
  f(y)
def f(x: Int): Unit =
  println(x)
def g[@inline x: _](y: x): Unit =
  f(y)
}

It appears that this error case can be simplified into this single line:

def g[@inline x: _](y: x): Unit = ()

Given to the REPL, this produces an assertion error instead of a syntax error:

Exception in thread "main" java.lang.AssertionError: assertion failed: end of NoSpan
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:10)
	at dotty.tools.dotc.util.Spans$Span$.end$extension(Spans.scala:51)
	at dotty.tools.dotc.parsing.Parsers$Parser.contextBound(Parsers.scala:2333)
	...
	at dotty.tools.repl.Main.main(Main.scala)

The bug occurs because _ is parsed as a placeholder type and receives NoSpan, while
contextBound() assumes that a tree always has a valid span.

Thanks to OSTIF/Quarkslab for finding this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions