Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[red-knot] Change Type::member to return a Result and rename it to try_member #16298

Open
MichaReiser opened this issue Feb 21, 2025 · 0 comments
Labels
red-knot Multi-file analysis & type inference

Comments

@MichaReiser
Copy link
Member

MichaReiser commented Feb 21, 2025

Description

Similar to Type::try_call, try_iterate, try_bool, ..., member should be renamed to try_member and return Result.

  • I don't think it should be LookupResult: Instead, it should be a result specific to Type::member because we may want to preserve additional error information for better diagnostics that isn't relevant when doing other symbol lookups. But I might be wrong here
  • I don't think try_member should return a Symbol because it behaves slightly different from all other type methods in that it doesn't necessarily consider a possibly unbound symbol as an error (but it probably is one for most type checking code).

We could offer helper methods to easily convert a Result<Type, MemberError> to a Result<Type, LookupError> or Symbol (e.g. implement From for Result<Type, LookupError> so that the try operator "just works").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

No branches or pull requests

1 participant