-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Interactive.pathTo
contains Literal(Constant(null))
as a head of path for incomplete program
#15294
Comments
@tanishiking I think this is at least arguably working as intended? I recently made some changes (some of which @odersky largely rewrote) to add the errorTermTree in more places for incomplete parses. The motivation in those PRs (e.g. #14463) was to differentiate between e.g. I think Metals should expect to see the |
As an example, suppose you had object Definition { def x = } It would be nice to know whether the cursor is on the left or the right side of the Now that I think about it, there's a pretty good chance that the |
@adampauls Thank you for the input!
In this usecase, I assume the cursor is on the right side of I think it's ok to have |
Well, I was specifically trying to argue it is useful in general :) I agree it's not for your use case and you are doing the right thing by ignoring. But suppose you have object Object {
def foo: Unit = •
} where • is the cursor. Unless I'm mistaken, without the error term tree, you might as well have the cursor on the So I'd hate to change pathTo since I would argue it's doing the right thing here. Though of course if you prefer one can have the current |
Off-topic, but this is intriguing :), is this something you could share more information on? More on-topic: I think it's worth adding a comment to pathTo mentioning that it might return |
The short story is that we had a need for a programming language targeting an internal runtime. One camp wanted to build something from scratch and one camp wanted to do something like ScalaJS/Native where we reuse the Scala compiler as the front end, and we ended up in a middle ground where we reuse some parts of the Scala ecosystem but also built some stuff on our own. |
Ok, it's reasonable to keep the pathTo behavior, as it is doing the right thing and there's a usecase of errorTermTree. Also, we don't need to something like pathTiExcludingError as it's quite easy to ignore. |
I'll work on adding comments to
|
area:ide
Compiler version
3.1.3-RC2 and later
Minimized code
See: https://github.com/tanishiking/dotty-interactive-playground/blob/50ea5babab3d6d124b98597873af371765b97bf3/src/main/scala/Main.scala#L45-L64
Output
with
3.1.3-RC2
or laterwith 3.1.2
Expectation
Scala 3.1.3 should return the same result as Scala 3.1.2. There shouldn't be a
Literal(Constant(null))
.Additional context
This is a bit of a problem for Metals, for example, when Metals try to invoke advanced completion based on the path to the cursor position something like
def |
(|
represents the cursor position).As a workaround Metals ignore
Literas(Constant(null))
.https://github.com/scalameta/metals/blob/92d8d9ecdaead1a6db2a9ebb1a85500c22c4714d/mtags/src/main/scala-3/scala/meta/internal/pc/completions/Completions.scala#L136-L139
The text was updated successfully, but these errors were encountered: