-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference
Milestone
Description
Red knot currently panics when encountering this self-referential generic class definition from typeshed:
class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr], None]):
def __next__(self) -> DirEntry[AnyStr]: ...
def __exit__(self, *args: Unused) -> None: ...
def close(self) -> None: ...A slightly simplified example to reproduce the same crash is this "CRTP style" example:
class GenericBase[T]: ...
class Derived[T](GenericBase[Derived[T]]): ...Strangely enough, the error does not appear if we remove the generic parameter from Derived. This works:
class Derived(list[Derived]): ...This does not:
class Derived[T](list[Derived[T]]): ...Stack trace of the panic
thread '<unnamed>' panicked at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/runtime.rs:341:13:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:734:5
1: std::panic::panic_any
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:259:5
2: salsa::runtime::Runtime::unblock_cycle_and_maybe_throw
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/runtime.rs:341:13
3: salsa::runtime::Runtime::block_on_or_unwind
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/runtime.rs:191:13
4: salsa::zalsa::Zalsa::block_on_or_unwind
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/zalsa.rs:277:9
5: salsa::table::sync::SyncTable::claim
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/table/sync.rs:71:17
6: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:64:28
7: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:67
8: core::option::Option<T>::or_else
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1545:21
9: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:33
10: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:13:20
11: red_knot_python_semantic::types::infer::infer_deferred_types::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:278:25
12: salsa::attach::Attached::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:71:9
13: salsa::attach::attach::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:23
14: std::thread::local::LocalKey<T>::try_with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:283:12
15: std::thread::local::LocalKey<T>::with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:260:9
16: salsa::attach::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:5
17: red_knot_python_semantic::types::infer::infer_deferred_types
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:270:13
18: red_knot_python_semantic::types::definition_expression_ty
at ./crates/red_knot_python_semantic/src/types.rs:214:13
19: <red_knot_python_semantic::types::Class as red_knot_python_semantic::types::Class::explicit_bases_query::InnerTrait_>::inner_fn_name_::{{closure}}
at ./crates/red_knot_python_semantic/src/types.rs:2442:30
20: core::iter::adapters::map::map_fold::{{closure}}
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:88:28
21: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/slice/iter/macros.rs:232:27
22: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:128:9
23: core::iter::traits::iterator::Iterator::for_each
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/iterator.rs:813:9
24: alloc::vec::Vec<T,A>::extend_trusted
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/mod.rs:3121:17
25: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/spec_extend.rs:26:9
26: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/spec_from_iter_nested.rs:60:9
27: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/spec_from_iter.rs:33:9
28: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/mod.rs:2985:9
29: core::iter::traits::iterator::Iterator::collect
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/iterator.rs:2000:9
30: <alloc::boxed::Box<[I]> as core::iter::traits::collect::FromIterator<I>>::from_iter
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/boxed.rs:2288:9
31: core::iter::traits::iterator::Iterator::collect
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/iterator.rs:2000:9
32: <red_knot_python_semantic::types::Class as red_knot_python_semantic::types::Class::explicit_bases_query::InnerTrait_>::inner_fn_name_
at ./crates/red_knot_python_semantic/src/types.rs:2439:9
33: <red_knot_python_semantic::types::Class::explicit_bases_query::inner_fn_name_::Configuration_ as salsa::function::Configuration>::execute::inner_
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_method_body.rs:34:17
34: <red_knot_python_semantic::types::Class::explicit_bases_query::inner_fn_name_::Configuration_ as salsa::function::Configuration>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:179:21
35: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:43
36: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
37: std::panicking::try::do_call
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
38: __rust_try
39: std::panicking::try
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
40: std::panic::catch_unwind
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
41: salsa::cycle::Cycle::catch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/cycle.rs:42:15
42: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:27
43: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:86:14
44: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:67
45: core::option::Option<T>::or_else
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1545:21
46: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:33
47: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:13:20
48: red_knot_python_semantic::types::Class::explicit_bases_query::inner_fn_name_::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:278:25
49: salsa::attach::Attached::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:71:9
50: salsa::attach::attach::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:23
51: std::thread::local::LocalKey<T>::try_with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:283:12
52: std::thread::local::LocalKey<T>::with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:260:9
53: salsa::attach::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:5
54: red_knot_python_semantic::types::Class::explicit_bases_query::inner_fn_name_
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:270:13
55: red_knot_python_semantic::types::Class::explicit_bases_query
at ./crates/red_knot_python_semantic/src/types.rs:2400:1
56: red_knot_python_semantic::types::Class::explicit_bases
at ./crates/red_knot_python_semantic/src/types.rs:2421:9
57: red_knot_python_semantic::types::Class::fully_static_explicit_bases
at ./crates/red_knot_python_semantic/src/types.rs:2426:9
58: <red_knot_python_semantic::types::Class as red_knot_python_semantic::types::Class::try_metaclass::InnerTrait_>::inner_fn_name_
at ./crates/red_knot_python_semantic/src/types.rs:2519:32
59: <red_knot_python_semantic::types::Class::try_metaclass::inner_fn_name_::Configuration_ as salsa::function::Configuration>::execute::inner_
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_method_body.rs:34:17
60: <red_knot_python_semantic::types::Class::try_metaclass::inner_fn_name_::Configuration_ as salsa::function::Configuration>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:179:21
61: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:43
62: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
63: std::panicking::try::do_call
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
64: __rust_try
65: std::panicking::try
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
66: std::panic::catch_unwind
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
67: salsa::cycle::Cycle::catch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/cycle.rs:42:15
68: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:27
69: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:86:14
70: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:67
71: core::option::Option<T>::or_else
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1545:21
72: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:33
73: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:13:20
74: red_knot_python_semantic::types::Class::try_metaclass::inner_fn_name_::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:278:25
75: salsa::attach::Attached::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:71:9
76: salsa::attach::attach::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:23
77: std::thread::local::LocalKey<T>::try_with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:283:12
78: std::thread::local::LocalKey<T>::with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:260:9
79: salsa::attach::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:5
80: red_knot_python_semantic::types::Class::try_metaclass::inner_fn_name_
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:270:13
81: red_knot_python_semantic::types::Class::try_metaclass
at ./crates/red_knot_python_semantic/src/types.rs:2400:1
82: red_knot_python_semantic::types::Class::metaclass
at ./crates/red_knot_python_semantic/src/types.rs:2512:9
83: red_knot_python_semantic::types::Type::to_meta_type
at ./crates/red_knot_python_semantic/src/types.rs:1494:63
84: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_subscript_expression_types
at ./crates/red_knot_python_semantic/src/types/infer.rs:3891:37
85: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_subscript_expression
at ./crates/red_knot_python_semantic/src/types/infer.rs:3761:9
86: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_expression_impl
at ./crates/red_knot_python_semantic/src/types/infer.rs:2157:48
87: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_expression
at ./crates/red_knot_python_semantic/src/types/infer.rs:2122:9
88: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_tuple_expression::{{closure}}
at ./crates/red_knot_python_semantic/src/types/infer.rs:2292:35
89: core::iter::adapters::map::map_fold::{{closure}}
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:88:28
90: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/slice/iter/macros.rs:232:27
91: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:128:9
92: core::iter::traits::iterator::Iterator::for_each
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/traits/iterator.rs:813:9
93: alloc::vec::Vec<T,A>::extend_trusted
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/mod.rs:3121:17
94: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/vec/spec_extend.rs:26:9
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference