diff --git a/mypy/fastparse.py b/mypy/fastparse.py index 456e2e9a9a1b..5b0bbb1ada19 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -1285,6 +1285,10 @@ def visit_Index(self, n: Index) -> Node: # cast for mypyc's benefit on Python 3.9 return self.visit(cast(Any, n).value) + def visit_Match(self, n: Any) -> None: + self.fail("Match statement is not supported", + line=n.lineno, column=n.col_offset, blocker=True) + class TypeConverter: def __init__(self, diff --git a/mypy/test/testcheck.py b/mypy/test/testcheck.py index c71b9aeea626..b90647fbd26d 100644 --- a/mypy/test/testcheck.py +++ b/mypy/test/testcheck.py @@ -103,6 +103,8 @@ typecheck_files.append('check-python38.test') if sys.version_info >= (3, 9): typecheck_files.append('check-python39.test') +if sys.version_info >= (3, 10): + typecheck_files.append('check-python310.test') # Special tests for platforms with case-insensitive filesystems. if sys.platform in ('darwin', 'win32'): diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test new file mode 100644 index 000000000000..3bcac61855b4 --- /dev/null +++ b/test-data/unit/check-python310.test @@ -0,0 +1,7 @@ +[case testMatchStatementNotSupported] +# flags: --python-version 3.10 +match str(): # E: Match statement is not supported + case 'x': + 1 + '' + case _: + 1 + b''