diff --git a/mypy/traverser.py b/mypy/traverser.py index 378d44c67f47..038d948522f0 100644 --- a/mypy/traverser.py +++ b/mypy/traverser.py @@ -253,9 +253,9 @@ def visit_yield_expr(self, o: YieldExpr) -> None: o.expr.accept(self) def visit_call_expr(self, o: CallExpr) -> None: + o.callee.accept(self) for a in o.args: a.accept(self) - o.callee.accept(self) if o.analyzed: o.analyzed.accept(self) diff --git a/test-data/unit/check-python38.test b/test-data/unit/check-python38.test index b9c798b9530e..b9f9f2173ae1 100644 --- a/test-data/unit/check-python38.test +++ b/test-data/unit/check-python38.test @@ -573,6 +573,14 @@ def foo() -> None: [x := x + y for y in [1, 2, 3]] [builtins fixtures/dict.pyi] +[case testWalrusUsedBeforeDef] +# flags: --python-version 3.8 +class C: + def f(self, c: 'C') -> None: pass + +(x := C()).f(y) # E: Cannot determine type of "y" # E: Name "y" is used before definition +(y := C()).f(y) + [case testOverloadWithPositionalOnlySelf] # flags: --python-version 3.8 from typing import overload, Optional