You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a flag to ClassFieldInitialization::Instance indicating whether the instance field must have been intialized or not
Summary:
Currently, if a field declared on class toplevel is not initialized immediately on the class toplevel, we always assume that it must never have been initialized. E.g.
```
class Foo:
x: int
Foo.x # ERROR! This is banned because `x` must have never been initialized
```
But there are several cases where this assumption is too wide-sweeping. For example, when `x` is annotated as `ClassVar[int]`, or when `Foo` is defined in stub files (see D74035159), it's actually more desirable if we assume `x` is "magically initialized" somehow and avoid reporting errors on `Foo.x`.
This diff proposes we attach a small piece of data to `ClassFieldInitialization::Instance` indicating whether we should consider `x` to be "magically initialized", to make it possible to suppress relevant errors by default. Only the data is added in this diff -- no logic is reading from the data yet. We'll be adding downstream readers of the data in D74035159
Reviewed By: rchen152
Differential Revision: D74035160
fbshipit-source-id: e58a2f60208ccd7b7d5ca2e6d1b142f43c0a420f
0 commit comments