Skip to content

Panic in pyrefly/lib/alt/answers_solver.rs #1527

@alub

Description

@alub

Describe the Bug

Running Pyrefly 0.40.1 on Django source crashes as follows. Note this worked on 0.39.2.

$ pyrefly check ~/src/django
ERROR Thread panicked, shutting down: panicked at pyrefly/lib/alt/answers_solver.rs:650:13:
We should have checked Exports before calling this, tests.model_fields.test_manytomanyfield KeyExport(Name("Child"))
Backtrace:
   0: pyrefly_util::panic::print_panic::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/crates/pyrefly_util/src/panic.rs:37:13
   1: std::sync::poison::once::Once::call_once::{{closure}}
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/sync/poison/once.rs:155:41
   2: std::sys::sync::once::futex::Once::call
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/sys/sync/once/futex.rs:178:21
   3: std::sync::poison::once::Once::call_once
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/sync/poison/once.rs:155:20
   4: pyrefly_util::panic::print_panic
             at /usr/src/debug/pyrefly/pyrefly/crates/pyrefly_util/src/panic.rs:34:16
   5: pyrefly_util::panic::exit_on_panic::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/crates/pyrefly_util/src/panic.rs:58:9
   6: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/alloc/src/boxed.rs:1985:9
   7: std::panicking::rust_panic_with_hook
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:841:13
   8: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:706:13
   9: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/sys/backtrace.rs:174:18
  10: __rustc::rust_begin_unwind
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:697:5
  11: core::panicking::panic_fmt
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/panicking.rs:75:14
  12: pyrefly::alt::answers_solver::AnswersSolver<Ans>::get_from_export::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:650:13
  13: core::option::Option<T>::unwrap_or_else
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/option.rs:1060:21
  14: pyrefly::alt::answers_solver::AnswersSolver<Ans>::get_from_export
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:649:47
  15: pyrefly::alt::class::django::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::resolve_foreign_key_target
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/django.rs:144:18
  16: pyrefly::alt::class::django::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::get_django_field_type_from_class
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/django.rs:108:43
  17: pyrefly::alt::class::django::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::get_django_field_type
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/django.rs:59:42
  18: pyrefly::alt::class::class_field::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::get_special_class_field_type::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/class_field.rs:1473:18
  19: core::option::Option<T>::or_else
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/option.rs:1647:21
  20: pyrefly::alt::class::class_field::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::get_special_class_field_type
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/class_field.rs:1468:10
  21: pyrefly::alt::class::class_field::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::calculate_class_field
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/class_field.rs:1351:49
  22: pyrefly::alt::solve::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::solve_class_field
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/solve.rs:1749:33
  23: <pyrefly::binding::binding::KeyClassField as pyrefly::alt::traits::Solve<Ans>>::solve
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/traits.rs:273:17
  24: pyrefly::alt::answers_solver::AnswersSolver<Ans>::calculate_and_record_answer
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:563:22
  25: pyrefly::alt::answers_solver::AnswersSolver<Ans>::get_idx
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:509:26
  26: pyrefly::alt::answers_solver::AnswersSolver<Ans>::get_from_module
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:637:23
  27: pyrefly::alt::answers_solver::AnswersSolver<Ans>::get_from_class
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:665:14
  28: pyrefly::alt::class::classdef::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::get_class_field_map
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/class/classdef.rs:127:39
  29: pyrefly::alt::solve::<impl pyrefly::alt::answers_solver::AnswersSolver<Ans>>::solve_consistent_override_check
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/solve.rs:1676:39
  30: <pyrefly::binding::binding::KeyConsistentOverrideCheck as pyrefly::alt::traits::Solve<Ans>>::solve
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/traits.rs:158:17
  31: pyrefly::alt::answers_solver::AnswersSolver<Ans>::calculate_and_record_answer
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:563:22
  32: pyrefly::alt::answers_solver::AnswersSolver<Ans>::get_idx
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers_solver.rs:509:26
  33: pyrefly::alt::answers::Answers::solve::pre_solve
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers.rs:425:33
  34: pyrefly::alt::answers::Answers::solve::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/alt/answers.rs:445:47
  35: pyrefly::alt::answers::Answers::solve
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/binding/table.rs:212:9
  36: pyrefly::state::steps::Step::step_solutions
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/state/steps.rs:199:35
  37: pyrefly::state::steps::Step::compute::{{closure}}::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/state/steps.rs:100:27
  38: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/ops/function.rs:253:5
  39: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/alloc/src/boxed.rs:1971:9
  40: pyrefly::state::state::Transaction::demand
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/state/state.rs:752:23
  41: pyrefly::state::state::Transaction::work::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/state/state.rs:1130:18
  42: pyrefly_util::task_heap::TaskHeap<K,V>::work
             at /usr/src/debug/pyrefly/pyrefly/crates/pyrefly_util/src/task_heap.rs:180:25
  43: pyrefly::state::state::Transaction::work
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/state/state.rs:1129:24
  44: pyrefly::state::state::Transaction::run_step::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/pyrefly/lib/state/state.rs:1162:37
  45: pyrefly_util::thread_pool::ThreadPool::spawn_many::{{closure}}::{{closure}}
             at /usr/src/debug/pyrefly/pyrefly/crates/pyrefly_util/src/thread_pool.rs:112:37
  46: rayon_core::scope::Scope::spawn::{{closure}}::{{closure}}
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/scope/mod.rs:531:57
  47: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/panic/unwind_safe.rs:272:9
  48: std::panicking::catch_unwind::do_call
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:589:40
  49: __rust_try
  50: std::panicking::catch_unwind
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:552:19
  51: std::panic::catch_unwind
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panic.rs:359:14
  52: rayon_core::unwind::halt_unwinding
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/unwind.rs:17:5
  53: rayon_core::scope::ScopeBase::execute_job_closure
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/scope/mod.rs:693:28
  54: rayon_core::scope::ScopeBase::execute_job
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/scope/mod.rs:683:29
  55: rayon_core::scope::Scope::spawn::{{closure}}
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/scope/mod.rs:531:13
  56: <rayon_core::job::HeapJob<BODY> as rayon_core::job::Job>::execute
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/job.rs:169:9
  57: rayon_core::job::JobRef::execute
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/job.rs:64:9
  58: rayon_core::registry::WorkerThread::execute
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:866:13
  59: rayon_core::registry::WorkerThread::wait_until_cold
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:800:26
  60: rayon_core::registry::WorkerThread::wait_until
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:775:18
  61: rayon_core::registry::WorkerThread::wait_until_out_of_work
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:824:14
  62: rayon_core::registry::main_loop
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:929:19
  63: rayon_core::registry::ThreadBuilder::run
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:50:18
  64: <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}
             at /build/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rayon-core-1.13.0/src/registry.rs:95:27
  65: std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/sys/backtrace.rs:158:18
  66: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/thread/mod.rs:559:17
  67: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/panic/unwind_safe.rs:272:9
  68: std::panicking::catch_unwind::do_call
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:589:40
  69: __rust_try
  70: std::panicking::catch_unwind
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panicking.rs:552:19
  71: std::panic::catch_unwind
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/panic.rs:359:14
  72: std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/thread/mod.rs:557:30
  73: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/core/src/ops/function.rs:253:5
  74: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/alloc/src/boxed.rs:1971:9
  75: std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/library/std/src/sys/pal/unix/thread.rs:107:17
  76: <unknown>
  77: <unknown>

PANIC Sorry, Pyrefly crashed, this is always a bug in Pyrefly itself.
PANIC Please report the bug at https://github.com/facebook/pyrefly/issues/new

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions