Skip to content

New semantic analyzer: Report undefined names in function types #6479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypy/newsemanal/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,11 @@ def _visit_func_def(self, defn: FuncDef) -> None:
# Signature must be analyzed in the surrounding scope so that
# class-level imported names and type variables are in scope.
analyzer = self.type_analyzer()
defn.type = analyzer.visit_callable_type(defn.type, nested=False)
tag = self.track_incomplete_refs()
result = analyzer.visit_callable_type(defn.type, nested=False)
if self.found_incomplete_ref(tag):
return
defn.type = result
self.add_type_alias_deps(analyzer.aliases_used)
self.check_function_signature(defn)
if isinstance(defn, FuncDef):
Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/check-newsemanal.test
Original file line number Diff line number Diff line change
Expand Up @@ -1702,3 +1702,7 @@ from typing import Tuple
c: C
class C(Tuple[int, str]):
def __init__(self) -> None: pass

[case testNewAnalyzerFunctionError]
def f(x: asdf) -> None: # E: Name 'asdf' is not defined
pass