Skip to content

Error tree on outdent is zero extent #23796

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ object Parsers {
false
}

def errorTermTree(start: Offset): Tree = atSpan(Span(start, in.offset)) { unimplementedExpr }
def errorTermTree(start: Offset): Tree =
val end = if in.token == OUTDENT then start else in.offset
atSpan(Span(start, end)) { unimplementedExpr }

private var inFunReturnType = false
private def fromWithinReturnType[T](body: => T): T = {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ object Scanners {
println(s"\nSTART SKIP AT ${sourcePos().line + 1}, $this in $currentRegion")
var noProgress = 0
// Defensive measure to ensure we always get out of the following while loop
// even if source file is weirly formatted (i.e. we never reach EOF)
// even if source file is weirdly formatted (i.e. we never reach EOF)
var prevOffset = offset
while !atStop && noProgress < 3 do
nextToken()
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ trait Checking {
typr.println(i"check no double declarations $cls")

def checkDecl(decl: Symbol): Unit = {
for (other <- seen(decl.name) if !decl.isAbsent() && !other.isAbsent()) {
for other <- seen(decl.name) if decl.name != nme.ERROR && !decl.isAbsent() && !other.isAbsent() do
typr.println(i"conflict? $decl $other")
def javaFieldMethodPair =
decl.is(JavaDefined) && other.is(JavaDefined) &&
Expand All @@ -1356,7 +1356,6 @@ trait Checking {
if decl.hasDefaultParams && other.hasDefaultParams then
report.error(em"two or more overloaded variants of $decl have default arguments", decl.srcPos)
decl.resetFlag(HasDefaultParams)
}
if (!excludeFromDoubleDeclCheck(decl))
seen(decl.name) = decl :: seen(decl.name)
}
Expand Down
19 changes: 19 additions & 0 deletions tests/neg/i23729.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

trait Collection[Self, Element]:
type Index
extension (self: Self)
def start: Index

sealed trait Tree[+T]
object Tree:
case object Empty extends Tree[Nothing]
case class Node[+T](value: T, lhs: Tree[T], rhs: Tree[T]) extends Tree[T]

enum Direction:
case Left, Right, Here
given [T]: Collection[Tree[T], T] with
type Index = List[Direction]
extension (self: Tree[T])
def start: List[Direction] = match self // error syntax
case Empty => Nil // error poor recovery
case Node(_, l, _) => l.start :+ Left // error poor recovery
Loading