Files
openide/python/testData/resolve/NoResolveInstanceAttrSameLine.py
Andrey Vlasovskikh 60da953814 PY-45206 Resolve instance attributes found in the same scope using control flow
We have to define a resolve order so that the attribute is never defined in terms of itself. The main result is preventing recursion in the type checker in case of an infinite loop. It used to cause unstable type inference based on the order in which we process elements.

A side effect of this change is a more precise behaviour of resolve for attributes where they are clearly not defined yet like:

    class C:
        def f(self):
            print(self.foo)  # foo is now unresolved
            self.foo = 0

See more examples in the unit tests for this fix.

GitOrigin-RevId: a791ed9a16df64935bf70e2933428c0950e5e7d3
2021-03-30 14:26:49 +00:00

5 lines
99 B
Python

class C:
def f(self):
self.foo = [1, 2, self.foo]
# <ref>