Skip to content

Commit cfc6941

Browse files
[red-knot] Resolve references in eager nested scopes eagerly (#16079)
We now resolve references in "eager" scopes correctly — using the bindings and declarations that are visible at the point where the eager scope is created, not the "public" type of the symbol (typically the bindings visible at the end of the scope). --------- Co-authored-by: Alex Waygood <[email protected]>
1 parent f50849a commit cfc6941

File tree

7 files changed

+645
-47
lines changed

7 files changed

+645
-47
lines changed

crates/red_knot_python_semantic/resources/mdtest/comprehensions/basic.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class IntIterable:
4343
def __iter__(self) -> IntIterator:
4444
return IntIterator()
4545

46-
# TODO: This could be a `tuple[int, int]` if we model that `y` can not be modified in the outer comprehension scope
47-
# revealed: tuple[int, Unknown | int]
46+
# revealed: tuple[int, int]
4847
[[reveal_type((x, y)) for x in IntIterable()] for y in IntIterable()]
4948
```
5049

@@ -67,8 +66,7 @@ class IterableOfIterables:
6766
def __iter__(self) -> IteratorOfIterables:
6867
return IteratorOfIterables()
6968

70-
# TODO: This could be a `tuple[int, int]` (see above)
71-
# revealed: tuple[int, Unknown | IntIterable]
69+
# revealed: tuple[int, IntIterable]
7270
[[reveal_type((x, y)) for x in y] for y in IterableOfIterables()]
7371
```
7472

0 commit comments

Comments
 (0)