Skip to content

Panic in report mode when @no_type_check decorator is used #3187

@amjames

Description

@amjames

Describe the Bug

Minimal repro below, real example was running pyrefly report pointed at torch/testing/_internal/common_fsdp.py (codepointer) codex minified this down to the @no_type_check decorator.

# Repro command:
#   uvx pyrefly report repro.py

from typing import no_type_check


@no_type_check
def f(x: int):
    pass

Log

ERROR Thread panicked, shutting down: panicked at pyrefly/lib/binding/bindings.rs:429:13:
Internal error: key not found, module `repro`, path `/.../repro.py`, key Hashed { hash: StarlarkHashValue(3454569666), key: Annotation(ShortIdentifier(114..115)) }
Backtrace:
   0:        0x102fe2450 - <std[2f7cd32bf4beae4b]::backtrace::Backtrace>::create
   1:        0x102e64ba8 - <std[2f7cd32bf4beae4b]::sync::once::Once>::call_once::<pyrefly_util[4cac38fcd6c06356]::panic::print_panic::{closure#0}>::{closure#0}
   2:        0x103155a58 - <std[2f7cd32bf4beae4b]::sys::sync::once::queue::Once>::call
   3:        0x102e64a88 - pyrefly_util[4cac38fcd6c06356]::panic::print_panic
   4:        0x102e65de8 - pyrefly_util[4cac38fcd6c06356]::panic::exit_on_panic::{closure#0}
   5:        0x102fbe248 - std[2f7cd32bf4beae4b]::panicking::panic_with_hook
   6:        0x102fddfe0 - std[2f7cd32bf4beae4b]::panicking::panic_handler::{closure#0}
   7:        0x102fddf9c - std[2f7cd32bf4beae4b]::sys::backtrace::__rust_end_short_backtrace::<std[2f7cd32bf4beae4b]::panicking::panic_handler::{closure#0}, !>
   8:        0x102fde57c - __rustc[f6c708c0d8e4bdd6]::rust_begin_unwind
   9:        0x1030d2b70 - core[1fab243bf906de66]::panicking::panic_fmt
  10:        0x10311bf64 - <pyrefly[139b3353b4c446b9]::binding::bindings::Bindings>::key_to_idx_hashed::<pyrefly[139b3353b4c446b9]::binding::binding::KeyAnnotation>::{closure#0}
  11:        0x102c28e34 - <pyrefly[139b3353b4c446b9]::commands::report::ReportArgs>::parse_functions
  12:        0x102c21150 - <pyrefly[139b3353b4c446b9]::commands::report::ReportArgs>::run_inner
  13:        0x10254b5fc - <pyrefly[139b3353b4c446b9]::commands::all::Command>::run::<pyrefly_util[4cac38fcd6c06356]::telemetry::NoTelemetry>::{closure#0}
  14:        0x1025585d4 - pyrefly[1ba7cf35f81b1e10]::main::{closure#0}
  15:        0x10256670c - pyrefly[1ba7cf35f81b1e10]::main
  16:        0x1024f1f7c - std[2f7cd32bf4beae4b]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> std[2f7cd32bf4beae4b]::process::ExitCode, std[2f7cd32bf4beae4b]::process::ExitCode>
  17:        0x10257b250 - _main

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

Labels

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