[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:
Dylan 2024-08-23 21:31:36 -05:00 committed by GitHub
parent d19fd1b91c
commit 8c09496b07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 16 deletions

View file

@ -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())