scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.81k stars 1.05k forks source link

completion of back-ticked members does not give backticks in REPL #14006

Closed bjornregnell closed 2 years ago

bjornregnell commented 2 years ago

Compiler version

3.1.0

Minimized code and output

Welcome to Scala 3.1.0 (11.0.11, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> enum BT { case `back-tick thing` }
// defined class BT

scala> BT.back-tick thing   //completed after pressing TAB on BT.back<TAB>
-- Error:
1 |BT.back-tick thing
  |^^^^^^^^^^^^
  |postfix operator `thing` needs to be enabled
  |by making the implicit value scala.language.postfixOps visible.
  |----
  |This can be achieved by adding the import clause 'import scala.language.postfixOps'
  |or by setting the compiler option -language:postfixOps.
  |See the Scaladoc for value scala.language.postfixOps for a discussion
  |why the feature needs to be explicitly enabled.

Expectation

The completion of back-ticked names should be wrapped into back-ticks so that the code works. A beginner might not know the rules of an identifier and a back-ticked member not following the rules is silently showing up in the list of completions. This may cause confusion.

It would also be nice if completion worked also after typing a back-tick.

scala> BT.`back-tick thing`  // completion does not work
val res0: BT = back-tick thing
prolativ commented 2 years ago

This seems related to https://github.com/lampepfl/dotty/pull/13369

ckipp01 commented 2 years ago

Just to tie these together this also seems a duplicate of https://github.com/lampepfl/dotty/issues/4406.

I have a working POC locally

2022-02-26 14 19 20

But I'm still trying to fix some issues that were also noticed in https://github.com/lampepfl/dotty/pull/13369 when you are trying to start the completion with a backtick for example you end up getting your completion, but it then begins with two backticks, so I need to figure that out. Looks like this was also hit on in https://github.com/lampepfl/dotty/pull/11794.

All that to say, I'm working on this.

som-snytt commented 2 years ago

They might have one of the old contributor's t-shirts lying around for you, that says:

You tick my back and I'll tick yours!