Skip to content

Crash report on missing closing parenthesis #19087

Closed
@JD557

Description

@JD557

Compiler version

3.3.1

Minimized code

I forgot to close some parenthesis and got a compiler crash instead of a compilation error.

Tested in Scala-cli

case class State(x: Int)

def foo[T](state: State)(body: => T): Option[T]
  Option.when(state.x == 0) body

var bar = 0
val state = State(0)

def app: Function1[Int, Unit] =
  new Function1[Int, Unit]:
    def apply(x: Int): Unit =
      foo(state):
        foo(state.copy(x = 5): // Missing ")"
          println("a")
      bar = 2

Output (click arrow to expand)

[error] .\paren.sc:4:33
[error] expression expected but end of statement found
[error]   Option.when(state.x == 0) body
[error]                                 ^
[error] .\paren.sc:15:11
[error] expression expected but = found
[error]       bar = 2
[error]           ^
exception occurred while parser D:\Projects\cli-tests\.scala-build\cli-tests_103be31561-147eb5c58d\src_generated\main\paren.scala

  exception occurred while compiling List(D:\Projects\cli-tests\.scala-build\cli-tests_103be31561-147eb5c58d\src_generated\main\paren.scala)

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: <no file>
        during phase: <no phase>
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.10
    compiler version: version 3.3.1
            settings: -bootclasspath C:\Coursier\Cache\https\repo1.maven.org\maven2\org\scala-lang\scala3-library_3\3.3.1\scala3-library_3-3.3.1.jar;C:\Coursier\Cache\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.10\scala-library-2.13.10.jar -classpath D:\Projects\cli-tests\.scala-build\.bloop\cli-tests_103be31561-147eb5c58d\bloop-internal-classes\main-eiQ3lMiATK-9XMWTRe3v2Q==;D:\Projects\cli-tests\.scala-build\cli-tests_103be31561-147eb5c58d\classes\classes-empty-cli-tests_103be31561-147eb5c58d -d D:\Projects\cli-tests\.scala-build\.bloop\cli-tests_103be31561-147eb5c58d\bloop-internal-classes\main-eiQ3lMiATK-9XMWTRe3v2Q== -java-output-version 17 -sourceroot D:\Projects\cli-tests

                tree: EmptyTree
       tree position: :<unknown>
           tree type: <notype>
              symbol: val <none>
           call site: package <root> in module class <root>

  == Source file context for tree position ==


Error compiling project (Scala 3.3.1, JVM (17))
Error: Unexpected error when compiling cli-tests_103be31561-147eb5c58d: 'assertion failed: position error, parent span does not contain child span
parent      =  extends Function1[Int, Unit] {
  def apply(x: Int): Unit =
    foo(state)(foo(state.copy(x = 5)(println("a")) bar null))
} # -1,
parent span = <283..424>,
child       = def apply(x: Int): Unit =
  foo(state)(foo(state.copy(x = 5)(println("a")) bar null)) # -1,
child span  = [313..317..476]'
Compilation failed

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