alephium / ralph-lsp

Ralph language server
7 stars 1 forks source link

Renaming should apply to all occurrences, not just the current member's scope #318

Closed simerplaha closed 3 weeks ago

simerplaha commented 1 month ago

This issue is for PR #314 (not merged).

In the following code, renaming the variable within the Child contract at line let copyInChild = variable renames all variable instances correctly, this is because all variable definitions in all super-types are within its scope. But renaming variable in Parent or any other super-type only renames variables that are within its local scope and its parent scope, which skips renaming references in subtypes.

Expected: Renaming the variable anywhere should rename all of its occurrences (parents and children), even if it's executed within the top super-type GreatGrandParent.

Abstract Contract GreatGrandParent(variable: Bool) { }

Abstract Contract GrandParent(variable: Bool) extends GreatGrandParent(variable) { }

Abstract Contract Parent(variable: Bool) extends GrandParent(variable) {
  pub fn parent() -> () {
    let copyInParent = variable
  }
}

Contract Child(variable: Bool) extends Parent(variable) {
  fn child() -> () {
    let copyInChild = variable
  }
}