Skip to content
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

Crash if class name is misspelled in match statement #12416

Closed
JukkaL opened this issue Mar 21, 2022 · 0 comments · Fixed by #12417
Closed

Crash if class name is misspelled in match statement #12416

JukkaL opened this issue Mar 21, 2022 · 0 comments · Fixed by #12417
Assignees
Labels
crash topic-match-statement Python 3.10's match statement

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Mar 21, 2022

This code causes a crash in mypy:

o: object
match o:
    case xyz():
        pass

Traceback:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/jukka/src/mypy/mypy/__main__.py", line 34, in <module>
    console_entry()
  File "/Users/jukka/src/mypy/mypy/__main__.py", line 12, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/Users/jukka/src/mypy/mypy/main.py", line 96, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "/Users/jukka/src/mypy/mypy/main.py", line 173, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/Users/jukka/src/mypy/mypy/build.py", line 180, in build
    result = _build(
  File "/Users/jukka/src/mypy/mypy/build.py", line 256, in _build
    graph = dispatch(sources, manager, stdout)
  File "/Users/jukka/src/mypy/mypy/build.py", line 2733, in dispatch
    process_graph(graph, manager)
  File "/Users/jukka/src/mypy/mypy/build.py", line 3077, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/jukka/src/mypy/mypy/build.py", line 3175, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/Users/jukka/src/mypy/mypy/build.py", line 2192, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/Users/jukka/src/mypy/mypy/checker.py", line 318, in check_first_pass
    self.accept(d)
  File "/Users/jukka/src/mypy/mypy/checker.py", line 424, in accept
    stmt.accept(self)
  File "/Users/jukka/src/mypy/mypy/nodes.py", line 1403, in accept
    return visitor.visit_match_stmt(self)
  File "/Users/jukka/src/mypy/mypy/checker.py", line 4121, in visit_match_stmt
    pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
  File "/Users/jukka/src/mypy/mypy/checker.py", line 4121, in <listcomp>
    pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
  File "/Users/jukka/src/mypy/mypy/checkpattern.py", line 107, in accept
    result = o.accept(self)
  File "/Users/jukka/src/mypy/mypy/patterns.py", line 137, in accept
    return visitor.visit_class_pattern(self)
  File "/Users/jukka/src/mypy/mypy/checkpattern.py", line 466, in visit_class_pattern
    assert type_info is not None
AssertionError:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash topic-match-statement Python 3.10's match statement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant