Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Rename of class method does nothing if class instance later assigned to None #940

Open
huguesv opened this issue Apr 11, 2019 · 2 comments

Comments

@huguesv
Copy link
Contributor

huguesv commented Apr 11, 2019

VSCode, LS 0.2.53, Python 3.7 32-bit

Given this code:

class Calculatrice():
    def add_numbers(self, first, second):
        '''this is help for adding numbers'''
        try:
            return first + second
        except:
            return None
    def multiply_numbers(self, one, two):
        return one + two

calc = Calculatrice()
calc.add_numbers(1, 5)

calc = None

calculator2 = Calculatrice()
calculator2.add_numbers(1,1)
calculator2.multiply_numbers(2, 5)

Double click on add_numbers on the line calc.add_numbers(1, 5) and press F2, enter add_values
Result: nothing happens

Delete the calc = None line

Repeat the rename, now it works

image
rename-noresult.log

@MikhailArkhipov MikhailArkhipov self-assigned this Apr 12, 2019
@MikhailArkhipov MikhailArkhipov added bug Something isn't working feature: references labels Apr 12, 2019
@MikhailArkhipov MikhailArkhipov added this to the April 2019.1 milestone Apr 12, 2019
@MikhailArkhipov
Copy link

MikhailArkhipov commented Apr 12, 2019

Different from #932, appears to work for some references but not for this one specifically.

@MikhailArkhipov MikhailArkhipov removed this from the April 2019.1 milestone Apr 12, 2019
@MikhailArkhipov MikhailArkhipov removed their assignment Apr 12, 2019
@MikhailArkhipov
Copy link

Basically variant of #682. LS does not track variable reassignments and uses the last known value which evaluates to None. Tracking all reassignments along the code flow would incur additional memory increase.

@MikhailArkhipov MikhailArkhipov removed the bug Something isn't working label Apr 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants