mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
[red-knot] Resolve function annotations before adding function symbol (#13084)
This PR has the `SemanticIndexBuilder` visit function definition annotations before adding the function symbol/name to the builder. For example, the following snippet no longer causes a panic: ```python def bool(x) -> bool: Return True ``` Note: This fix changes the ordering of the global symbol table. Closes #13069
This commit is contained in:
parent
d19fd1b91c
commit
8c09496b07
5 changed files with 30 additions and 16 deletions
|
@ -575,7 +575,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
|
|||
let index = semantic_index(&db, file);
|
||||
let global_table = symbol_table(&db, global_scope(&db, file));
|
||||
|
||||
assert_eq!(names(&global_table), vec!["f", "str", "int"]);
|
||||
assert_eq!(names(&global_table), vec!["str", "int", "f"]);
|
||||
|
||||
let [(function_scope_id, _function_scope)] = index
|
||||
.child_scopes(FileScopeId::global())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue