report error when ambiguous `FunctionType` as `Enum` value
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 519
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
```py
from enum import Enum
def f() -> object:
return lambda: 1
class E(Enum):
a = f() # expect error: `object` can potentially be `FunctionType`, wrap this value with `enum.member` to enforce expected runtime behaviour
E.a.name # fails at runtime
```
`FunctionType` becomes a non-member, but currently pyrefly assumes a super type of `FunctionType` is a member, use `enum.member` to override this and make it a member
in this case i would expect `E.a` to become either `Unknown` or a type of `member | non-member`, either way i would expect an error message to be shown on the declaration of `E.a`
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.