mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
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
8 lines
115 B
Python
8 lines
115 B
Python
class C:
|
|
def f(self):
|
|
return self.foo
|
|
# <ref>
|
|
|
|
def g(self):
|
|
self.foo = 1
|