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

Incorrect positions / interactive path on mutiple variable declaration #22207

Open
kasiaMarek opened this issue Dec 13, 2024 · 3 comments
Open

Comments

@kasiaMarek
Copy link
Contributor

Compiler version

3.5.0

Minimized code

val xx, yy, zz = 1

Output

[[syntax trees at end of                     typer]] // demo.scala
package <empty>@demo.scala<0..0> {
  final lazy module val demo$package: demo$package@demo.scala<0..0> =
    new demo$package@demo.scala<0..0>@demo.scala<0..0>@demo.scala<0..0>()@
      demo.scala<0..0>
  @demo.scala<0..0>
  final module class demo$package() extends Object@demo.scala<0..0>@
    demo.scala<0..0>()@demo.scala<0..0> {
    this: demo$package@demo.scala<0..0>.type@demo.scala<0..0> =>
    val xx: Int = 1@demo.scala<17..18>@demo.scala[0..4..18]
    val yy: Int = 1@demo.scala<17..18>@demo.scala[0..8..18]
    val zz: Int = 1@demo.scala<17..18>@demo.scala[0..12..18]
  }@demo.scala<0..18>
}@demo.scala<0..18>

Problem

Start and end position for all definitions are the same. This leads to incorrect Interactive.pathTo for position on xx or yy definition -- head being zz definition.

Expectation

I would either expect positions on multiple declaration to be solved as in Scala 2 (though this is also buggy there):

xx -- `4..18`
yy --`8..18`
zz -- `12..18`

or for Interactive.pathTo to account for that situation.

@som-snytt
Copy link
Contributor

Isn't there namePos in dotty?

@Gedochao Gedochao removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Dec 16, 2024
@kasiaMarek
Copy link
Contributor Author

Isn't there namePos in dotty?

Yes there is. But Interactive.pathTo won't use that in any way... Or am I missing your point?

@som-snytt
Copy link
Contributor

On Scala 2, I'm experimenting with each valdef having the same transparent pos of the whole def, with point at the name, namePos for the name, and rhs as currently. I haven't look at how positions are used yet, or what it looks like in dotty.

The general form is that each pattern introduces multiple bindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants