Skip to content

Commit

Permalink
Fix semantic analysis of assignment expressions (#11153)
Browse files Browse the repository at this point in the history
Fixes half of #11060

Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja authored Sep 21, 2021
1 parent a7d6e68 commit d7bb840
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@ def analyze_name_lvalue(self,
self.msg.cant_assign_to_final(name, self.type is not None, lvalue)

kind = self.current_symbol_kind()
names = self.current_symbol_table()
names = self.current_symbol_table(escape_comprehensions=escape_comprehensions)
existing = names.get(name)

outer = self.is_global_or_nonlocal(name)
Expand Down
6 changes: 6 additions & 0 deletions test-data/unit/check-python38.test
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,9 @@ def main(a: object) -> None:
reveal_type(x) # N: Revealed type is "builtins.float"
reveal_type(a) # N: Revealed type is "builtins.object"
[builtins fixtures/tuple.pyi]

[case testWalrusRedefined]
def foo() -> None:
x = 0
[x := x + y for y in [1, 2, 3]]
[builtins fixtures/dict.pyi]

0 comments on commit d7bb840

Please sign in to comment.