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

Presentation Compiler should not fail fast #22217

Open
rochala opened this issue Dec 16, 2024 · 3 comments
Open

Presentation Compiler should not fail fast #22217

rochala opened this issue Dec 16, 2024 · 3 comments
Assignees
Labels
area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools itype:enhancement

Comments

@rochala
Copy link
Contributor

rochala commented Dec 16, 2024

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.

@rochala rochala added itype:enhancement area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools labels Dec 16, 2024
@Gedochao
Copy link
Contributor

cc @tgodzik @kasiaMarek

@tgodzik
Copy link
Contributor

tgodzik commented Dec 16, 2024

Would that just be a case of adding a try?

@rochala
Copy link
Contributor Author

rochala commented Dec 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools itype:enhancement
Projects
None yet
Development

No branches or pull requests

4 participants