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 when building a list from starred tuples #5770

Closed
pdeblanc opened this issue Oct 11, 2018 · 4 comments
Closed

Internal error when building a list from starred tuples #5770

pdeblanc opened this issue Oct 11, 2018 · 4 comments

Comments

@pdeblanc
Copy link

Using python 3.7.0, mypy 0.630.

Example file combine.py:

from typing import List, Tuple


def combine_tuples_into_list(a: Tuple[int, int], b: Tuple[int]) -> List[int]:
    return [*a, *b]

I then run mypy combine.py --show-traceback. Here's the output:

combine.py:5: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.630
Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/usr/local/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/usr/local/lib/python3.7/site-packages/mypy/main.py", line 91, in main
    res = type_check_only(sources, bin_dir, options, flush_errors, fscache)  # noqa
  File "/usr/local/lib/python3.7/site-packages/mypy/main.py", line 148, in type_check_only
    fscache=fscache)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 183, in build
    flush_errors, fscache)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 356, in _build
    graph = dispatch(sources, manager)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 2543, in dispatch
    process_graph(graph, manager)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 2840, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 2963, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 2103, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 256, in check_first_pass
    self.accept(d)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 355, in accept
    stmt.accept(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/nodes.py", line 603, in accept
    return visitor.visit_func_def(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 666, in visit_func_def
    self._visit_func_def(defn)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 670, in _visit_func_def
    self.check_func_item(defn, name=defn.name())
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 732, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 898, in check_func_def
    self.accept(item.body)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 355, in accept
    stmt.accept(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/nodes.py", line 885, in accept
    return visitor.visit_block(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 1607, in visit_block
    self.accept(s)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 355, in accept
    stmt.accept(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/nodes.py", line 1011, in accept
    return visitor.visit_return_stmt(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 2404, in visit_return_stmt
    self.check_return_stmt(s)
  File "/usr/local/lib/python3.7/site-packages/mypy/checker.py", line 2437, in check_return_stmt
    allow_none_return=allow_none_func_call)
  File "/usr/local/lib/python3.7/site-packages/mypy/checkexpr.py", line 2987, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/nodes.py", line 1691, in accept
    return visitor.visit_list_expr(self)
  File "/usr/local/lib/python3.7/site-packages/mypy/checkexpr.py", line 2461, in visit_list_expr
    return self.check_lst_expr(e.items, 'builtins.list', '<list>', e)
  File "/usr/local/lib/python3.7/site-packages/mypy/checkexpr.py", line 2487, in check_lst_expr
    context)[0]
  File "/usr/local/lib/python3.7/site-packages/mypy/checkexpr.py", line 627, in check_call
    callee, args, arg_kinds, formal_to_actual, context)
  File "/usr/local/lib/python3.7/site-packages/mypy/checkexpr.py", line 875, in infer_function_type_arguments
    strict=self.chk.in_checked_function())
  File "/usr/local/lib/python3.7/site-packages/mypy/infer.py", line 31, in infer_function_type_arguments
    callee_type, arg_types, arg_kinds, formal_to_actual)
  File "/usr/local/lib/python3.7/site-packages/mypy/constraints.py", line 60, in infer_constraints_for_callable
    tuple_counter)
  File "/usr/local/lib/python3.7/site-packages/mypy/constraints.py", line 88, in get_actual_type
    return arg_type.items[tuple_counter[0] - 1]
IndexError: list index out of range
combine.py:5: : note: use --pdb to drop into pdb
@emmatyping
Copy link
Collaborator

Confirmed on 0.630 and master with this simple repro:

from typing import Tuple
a: Tuple[int, int]
b: Tuple[int]
f = [*a, *b]

@ilevkivskyi
Copy link
Member

There is another crash with star expressions, #3825, but it looks lie this is unrelated.

@refi64
Copy link
Contributor

refi64 commented Jul 8, 2019

Was this fixed? Can't reproduce on master now.

@refi64
Copy link
Contributor

refi64 commented Jul 8, 2019

This was fixed by dd1c5d0.

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

No branches or pull requests

4 participants