<!-- Use this form only if mypy reports an "INTERNAL ERROR" and/or gives a traceback. Please include the traceback and all other messages below (use `mypy --show-traceback`). --> **Crash Report** The expression `x == y in z` crashes when used in `assert` and `if` statements (examples below). I have bisected it to https://github.com/python/mypy/commit/b91f53c1b2d4cd12bf4e15781e447ebdd72f2b42 @hauntsaninja It doesn't crash anymore when I add parenthesis to make it either `(x == y) in z` or `x == (y in z)`. **Traceback** ```python-traceback /Users/psawicki/test.py:6: error: INTERNAL ERROR -- Please try using mypy master on GitHub: https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build Please report a bug at https://github.com/python/mypy/issues version: 1.20.0+dev.b91f53c1b2d4cd12bf4e15781e447ebdd72f2b42 Traceback (most recent call last): File "/Users/psawicki/Code/mypy/venv3.13/bin/mypy", line 7, in <module> sys.exit(console_entry()) File "/Users/psawicki/Code/mypy/mypy/__main__.py", line 15, in console_entry main() File "/Users/psawicki/Code/mypy/mypy/main.py", line 135, in main res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr) File "/Users/psawicki/Code/mypy/mypy/main.py", line 219, in run_build res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr) File "/Users/psawicki/Code/mypy/mypy/build.py", line 351, in build result = build_inner( File "/Users/psawicki/Code/mypy/mypy/build.py", line 448, in build_inner graph = dispatch(sources, manager, stdout) File "/Users/psawicki/Code/mypy/mypy/build.py", line 3214, in dispatch process_graph(graph, manager) File "/Users/psawicki/Code/mypy/mypy/build.py", line 3625, in process_graph done, still_working, results = manager.wait_for_done(graph) File "/Users/psawicki/Code/mypy/mypy/build.py", line 1101, in wait_for_done process_stale_scc(graph, next_scc, self) File "/Users/psawicki/Code/mypy/mypy/build.py", line 3789, in process_stale_scc graph[id].type_check_first_pass() File "/Users/psawicki/Code/mypy/mypy/build.py", line 2579, in type_check_first_pass self.type_checker().check_first_pass() File "/Users/psawicki/Code/mypy/mypy/checker.py", line 531, in check_first_pass self.accept(d) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 642, in accept stmt.accept(self) File "/Users/psawicki/Code/mypy/mypy/nodes.py", line 1004, in accept return visitor.visit_func_def(self) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 1199, in visit_func_def self._visit_func_def(defn) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 1203, in _visit_func_def self.check_func_item(defn, name=defn.name) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 1238, in check_func_item self.check_func_def(defn, typ, name, allow_empty) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 1511, in check_func_def self.accept(item.body) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 642, in accept stmt.accept(self) File "/Users/psawicki/Code/mypy/mypy/nodes.py", line 1582, in accept return visitor.visit_block(self) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 3160, in visit_block self.accept(s) File "/Users/psawicki/Code/mypy/mypy/checker.py", line 642, in accept stmt.accept(self) ~~~~~~~~~~~^^^^^^ File "/Users/psawicki/Code/mypy/mypy/nodes.py", line 1795, in accept return visitor.visit_assert_stmt(self) ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/Users/psawicki/Code/mypy/mypy/checker.py", line 5138, in visit_assert_stmt true_map, else_map = self.find_isinstance_check(s.expr) ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ File "/Users/psawicki/Code/mypy/mypy/checker.py", line 6354, in find_isinstance_check if_map, else_map = self.find_isinstance_check_helper( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ node, in_boolean_context=in_boolean_context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/Users/psawicki/Code/mypy/mypy/checker.py", line 6455, in find_isinstance_check_helper return self.comparison_type_narrowing_helper(node) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/Users/psawicki/Code/mypy/mypy/checker.py", line 6626, in comparison_type_narrowing_helper if_map, else_map = self.narrow_type_by_equality( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "==", ^^^^^ ...<3 lines>... narrowable_indices={0}, ^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/Users/psawicki/Code/mypy/mypy/checker.py", line 6757, in narrow_type_by_equality typ = get_proper_type(operand_types[i]) ~~~~~~~~~~~~~^^^ IndexError: list index out of range ``` **To Reproduce** ```python def assert_has_key(has_key: bool, key: str, s: set[str]) -> None: assert has_key == key in s ``` or ```python def compare_has_key(has_key: bool, key: str, s: set[str]) -> None: if has_key == key in s: print("test") ``` **Your Environment** <!-- Include as many relevant details about the environment you experienced the bug in --> - Mypy version used: 1.20.0+dev.b91f53c1b2d4cd12bf4e15781e447ebdd72f2b42 and up - Mypy command-line flags: `mypy ~/test.py --show-traceback` - Mypy configuration options from `mypy.ini` (and other config files): None - Python version used: 3.13.5 - Operating system and version: macOS 15.7.3 <!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->