Skip to content

Commit

Permalink
[red-knot] Resolve references in eager nested scopes eagerly (#16079)
Browse files Browse the repository at this point in the history
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 <alex.waygood@gmail.com>
  • Loading branch information
dcreager and AlexWaygood authored Feb 19, 2025
1 parent f50849a commit cfc6941
Show file tree
Hide file tree
Showing 7 changed files with 645 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class IntIterable:
def __iter__(self) -> IntIterator:
return IntIterator()

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

Expand All @@ -67,8 +66,7 @@ class IterableOfIterables:
def __iter__(self) -> IteratorOfIterables:
return IteratorOfIterables()

# TODO: This could be a `tuple[int, int]` (see above)
# revealed: tuple[int, Unknown | IntIterable]
# revealed: tuple[int, IntIterable]
[[reveal_type((x, y)) for x in y] for y in IterableOfIterables()]
```

Expand Down
Loading

0 comments on commit cfc6941

Please sign in to comment.