-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Overriding definition such as type alias in a subclass causes a crash #5425
Comments
I think this is a new crash caused by the recent refactoring, previously type aliases were just |
As discussed in #5662, similar crashes are possible for other kinds of overrides. We should verify that all combinations of base class / subclass node types are handled correctly, including these:
|
I have an example for a crash on a trivial override (i.e. not changing the type):
Mypy:
|
Fixes #5846 The fix for crash is kind of straightforward. Previously `active_self_type()` always returned `None` at method scope (sic!) While working on this I discovered couple other problems: * Area around checking LSP is generally problematic (see also #5425 that I tried to fix earlier but failed). In particular, the are two ways to get current `TypeInfo`, one is from `lvalue.node.info` or `defn.info`, another is using `active_self_type()` (this is rather abusing it IMO). I don't try to fix this here (i.e. switch to always using one way) because this is a relatively large refactoring. * Currently in type checker we defer nested functions instead of top-level ones. I believe this is not by design and is rather caused by absence of docstrings and unintuitive method names in `CheckerScope` class. Namely, there "top function" stays for "top of stack function", not "top-level function". I don't try to fix this here either because this is conceptually a big change.
…same name as type alias work on python#5425
…same name as type alias work on python#5425
…same name as type alias (#13015) Work on #5425 Co-authored-by: Wesley Wright <[email protected]>
…same name as type alias (python#13015) Work on python#5425 Co-authored-by: Wesley Wright <[email protected]>
The following program crashes on both mypy 0.620 and the latest version on master:
(In this case, I meant to do
foo: Callable[..., int]
.)Here's the traceback:
I did a cursory skim of the existing crash issues, but maybe this is already a known issue? If so, feel free to close.
The text was updated successfully, but these errors were encountered: