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

Incomplete rename because of trailing commas #5095

Closed
susliko opened this issue Mar 27, 2023 · 5 comments
Closed

Incomplete rename because of trailing commas #5095

susliko opened this issue Mar 27, 2023 · 5 comments
Labels
bug Something that is making a piece of functionality unusable fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket rename

Comments

@susliko
Copy link
Contributor

susliko commented Mar 27, 2023

Describe the bug

Renaming type Bar in the following code

final case class Foo(
    a: <<Bar>>,
    b: Bar,
)
trait Bar

results in b: Bar left unrenamed

final case class Foo(
    a: Quux,
    b: Bar,
)
trait Quux

The same rename goes well when there is no trailing comma after b: Bar
Tested in VS Code and Nvim

Expected behavior

All occurences of type Bar replaced with Quux

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v0.11.11

Extra context or search terms

No response

@tgodzik
Copy link
Contributor

tgodzik commented Mar 27, 2023

Thanks for reporting! I think it's due to the bug in the compiler that @jkciesluk found, where the position of the last coma is included in the span of the last parameter. We have a special check that makes sure that what gets renamed is actually what we are renaming and this is probably causing the issue.

@tgodzik tgodzik added bug Something that is making a piece of functionality unusable rename labels Mar 27, 2023
@jkciesluk
Copy link
Member

Yes, this is caused by the trailing comma issue. It works fine when the rename is local, i.e.

def m() = {
  final case class Foo(
      a: Bar,
      b: Bar,
  )
  trait Bar
}

But when rename is possibly global (symbol is not defined inside a method), then there is a missmatch (type of B is Bar,)

@susliko
Copy link
Contributor Author

susliko commented Mar 27, 2023

Got it
Is there an issue for that compiler bug?

@jkciesluk
Copy link
Member

Yes, scala/scala3#16872

@kasiaMarek kasiaMarek added the fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket label Feb 18, 2025
@kasiaMarek
Copy link
Contributor

fixed by: scala/scala3#20445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket rename
Projects
None yet
Development

No branches or pull requests

4 participants