Skip to content

Presentation Compiler should not fail fast #22217

Open
@rochala

Description

@rochala
Contributor

Compiler version

All

Minimized code

Currently, when crash happens during completions calculation, no results are returned.
In my case, the failure happened in

scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        dotty.tools.dotc.typer.Typer$.assertPositioned(Typer.scala:76)
        dotty.tools.dotc.typer.Typer.typed(Typer.scala:3636)
        dotty.tools.dotc.typer.Applications.extMethodApply(Applications.scala:2630)
        dotty.tools.dotc.typer.Applications.extMethodApply$(Applications.scala:434)
        dotty.tools.dotc.typer.Typer.extMethodApply(Typer.scala:145)
        dotty.tools.dotc.typer.Applications.tryApplyingExtensionMethod(Applications.scala:2675)
        dotty.tools.dotc.typer.Applications.tryApplyingExtensionMethod$(Applications.scala:434)
        dotty.tools.dotc.typer.Typer.tryApplyingExtensionMethod(Typer.scala:145)
   dotty.tools.dotc.interactive.Completion$Completer.tryApplyingReceiverToExtension$1(Completion.scala:561)

The crash was encountered during extension member's completion calculation, and all other results were discarded or not computed. This is not ideal, as sometimes crashes are not related strictly to presentation compiler implementation.

The correct output should be a list of completions without extension members (ideally only those that actually crashed)

Reproduction

I tried completing

List(1, 2, 3).map(_.@@) 

in https://github.com/scala/scala3/blob/main/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala

With a crash:

java.lang.AssertionError: assertion failed: position not set for dotty.tools.pc.utils.InteractiveEnrichments.companion(<empty>) # -1 of class dotty.tools.dotc.ast.Trees$Apply in <WORKSPACE>/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala%

The crash above is not part of this issue, just a fact that presentation compiler should not fail fast.

Activity

Gedochao

Gedochao commented on Dec 16, 2024

@Gedochao
Contributor
tgodzik

tgodzik commented on Dec 16, 2024

@tgodzik
Contributor

Would that just be a case of adding a try?

rochala

rochala commented on Dec 16, 2024

@rochala
ContributorAuthor

In multiple places, yes. I've discussed this with @kasiaMarek, and it may be good to create a wrapper used for tracking each completion part + we could use this to report timings to find bottlenecks.

But overall it should be a multiple try catch clauses, ideally in every completion step so only one "Contributor" fails a time.

self-assigned this
on Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @tgodzik@Gedochao@kasiaMarek@rochala

      Issue actions

        Presentation Compiler should not fail fast · Issue #22217 · scala/scala3