Fix @no_type_check panic#3211
Conversation
Summary:
Add a regression test that reproduces the panic when running `pyrefly report` on functions decorated with `no_type_check`. The test currently asserts the panic behavior using `#[should_panic]`.
When running `pyrefly report` on a function like:
```python
from typing import no_type_check
no_type_check
def f(x: int):
pass
```
The report command panics at `pyrefly/lib/binding/bindings.rs:429` in `key_to_idx_hashed` with the error: "Internal error: key not found, module `<module>`, path `<path>`, key Annotation(ShortIdentifier(...))"
Root cause: The binding pass skips creating `KeyAnnotation` entries for parameters of `no_type_check` decorated functions (since their bodies are not analyzed), but `parse_functions` in `report.rs` unconditionally tries to look them up.
A follow-up diff will fix the panic and update this test to assert correct behavior instead of the panic.
Differential Revision: D102023871
|
@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102023871. |
|
Will symbols in |
good question. I imagine it shouldn't. what do you think? cc @maggiemoss |
Yea same, I think that those symbols should be ignored then. |
did you still want to take this over? or do you want me to finish it |
I guess that depends on how quickly you are able to get this in. Does next week sound realistic? |
|
closed from other fix, referenced in #3187 |
Summary:
Add a regression test that reproduces the panic when running
pyrefly reporton functions decorated withno_type_check. The test currently asserts the panic behavior using#[should_panic].When running
pyrefly reporton a function like:The report command panics at
pyrefly/lib/binding/bindings.rs:429inkey_to_idx_hashedwith the error: "Internal error: key not found, module<module>, path<path>, key Annotation(ShortIdentifier(...))"Root cause: The binding pass skips creating
KeyAnnotationentries for parameters ofno_type_checkdecorated functions (since their bodies are not analyzed), butparse_functionsinreport.rsunconditionally tries to look them up.A follow-up diff will fix the panic and update this test to assert correct behavior instead of the panic.
Differential Revision: D102023871