The name `Ellipsis` is handled incorrectly
Describe the Bug
class Ellipsis:
pass
def foo() -> Ellipsis:
return Ellipsis()
Pyre throws an error on the return line:
ERROR 6:12-20: Expected a callable, got EllipsisType [[not-callable](https://pyrefly.org/en/docs/error-kinds/#not-callable)]
Which seems to be a symptom of Ellipsis being resolved to the type of ...
Sandbox Link
https://pyrefly.org/sandbox/?code=MYGwhgzhAECiIgJYAcKIgLgFDV9ZkEWxAJgKYBm0FA9jQBQCU0AtAHxwIpqY54BOZAC4BXfgDtOSVOiZYgA
(Only applicable for extension issues) IDE Information
No response
The issue is that Python defines Ellipsis: EllipsisType in the builtins, so what you have is essentially:
from builtins import Ellipsis
class Ellipsis: ...
def foo():
Ellipsis()
When you are under a function we use the anywhere definition of Ellipsis, which includes any point in the module. That's means we end up not knowing which Ellipsis to use, and one of them fails.
The solution here is that a Anywhere usage should be paired with how far through the Anywhere we know we are when we create the binding. E.g. when we see Ellipsis() we know that the first Ellipsis is no longer accessible, but any subsequent redefinition of Ellipsis might be. That requires a bunch of replumbing, but would be good to do.