Skip to content

Rename and inline refactor did not recognize match-cases statements as variable assignment #861

Description

@lieryan

Describe the bug

The match statement allows pattern capture which effectively acts like an assignment statement. Currently they are not recognised as assignment statement that can define a variable.

To Reproduce
Steps to reproduce the behavior:

  1. Code before refactoring:
x = [1, 2, 3]
match x:
    case [1, *_] as old_name_1:
        print(old_name_1)
    case [2, *old_name_2]:
        print(old_name_2)
  1. Describe the refactoring you want to do: rename old_name_xxx to new_name_xxx

  2. Expected code after refactoring:

x = [1, 2, 3]
match x:
    case [1, *_] as new_name_1:
        print(new_name_1)
    case [2, *new_name_2]:
        print(new_name_2)
  1. Describe the error or unexpected result that you are getting
RefactoringError: Rename refactoring should be performed on resolvable python identifiers

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected or incorrect user-visible behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions