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

INTERNAL ERROR with NoReturn in a boolean operation #11679

Closed
KotlinIsland opened this issue Dec 8, 2021 · 2 comments · Fixed by #11680
Closed

INTERNAL ERROR with NoReturn in a boolean operation #11679

KotlinIsland opened this issue Dec 8, 2021 · 2 comments · Fixed by #11680
Labels

Comments

@KotlinIsland
Copy link
Contributor

from typing import NoReturn

a: NoReturn
a or 1
>mypy -V
mypy 0.920+dev.01e6aba30c787c664ac88d849b45f7d303316951
traceback
>mypy --show-traceback test.py
test.py:4: 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: 0.920+dev.01e6aba30c787c664ac88d849b45f7d303316951
Traceback (most recent call last):
  File "...\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "...\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "...\venv\Scripts\mypy.exe\__main__.py", line 7, in <module>
    sys.exit(console_entry())
  File "...\venv\lib\site-packages\mypy\__main__.py", line 12, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "...\venv\lib\site-packages\mypy\main.py", line 96, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "...\venv\lib\site-packages\mypy\main.py", line 173, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "...\venv\lib\site-packages\mypy\build.py", line 180, in build
    result = _build(
  File "...\venv\lib\site-packages\mypy\build.py", line 256, in _build
    graph = dispatch(sources, manager, stdout)
  File "...\venv\lib\site-packages\mypy\build.py", line 2715, in dispatch
    process_graph(graph, manager)
  File "...\venv\lib\site-packages\mypy\build.py", line 3046, in process_graph
    process_stale_scc(graph, scc, manager)
  File "...\venv\lib\site-packages\mypy\build.py", line 3144, in process_stale_scc
    graph[id].type_check_first_pass()
  File "...\venv\lib\site-packages\mypy\build.py", line 2180, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "...\venv\lib\site-packages\mypy\checker.py", line 319, in check_first_pass
    self.accept(d)
  File "...\venv\lib\site-packages\mypy\checker.py", line 425, in accept
    stmt.accept(self)
  File "...\venv\lib\site-packages\mypy\nodes.py", line 1087, in accept
    return visitor.visit_expression_stmt(self)
  File "...\venv\lib\site-packages\mypy\checker.py", line 3332, in visit_expression_stmt
    self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
  File "...\venv\lib\site-packages\mypy\checkexpr.py", line 3972, in accept
    typ = node.accept(self)
  File "...\venv\lib\site-packages\mypy\nodes.py", line 1828, in accept
    return visitor.visit_op_expr(self)
  File "...\venv\lib\site-packages\mypy\checkexpr.py", line 2197, in visit_op_expr
    return self.check_boolean_op(e, e)
  File "...\venv\lib\site-packages\mypy\checkexpr.py", line 2867, in check_boolean_op
    assert left_map is not None  # find_isinstance_check guarantees this
AssertionError:
test.py:4: : note: use --pdb to drop into pdb
@hauntsaninja
Copy link
Collaborator

Interesting. Something should probably return UninhabitedType.

@hauntsaninja
Copy link
Collaborator

Yeah, looks like even:

from typing import NoReturn

def f() -> NoReturn: ...

if f():
    pass
else:
    pass

breaks the "guarantee" of

Guaranteed to not return None, None. (But may return {}, {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants