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 during type inference with union of type variable and callable #674

Closed
JukkaL opened this issue May 15, 2015 · 0 comments
Closed

Crash during type inference with union of type variable and callable #674

JukkaL opened this issue May 15, 2015 · 0 comments
Labels
bug mypy got something wrong

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented May 15, 2015

Mypy crashes when inferring the call to f below:

from typing import Union, Callable, Match, TypeVar
T = TypeVar('T')
def f(x: T, y: Union[T, Callable[[T], None]]) -> None: pass
f('', '')

The above is about the simplest signature that seems to trigger the bug. In practice, a signature for re.sub also causes the crash (see #665).

Here's the traceback:

Traceback (most recent call last):
  File "scripts/mypy", line 182, in <module>
    main()
  File "scripts/mypy", line 36, in main
    type_check_only(path, module, bin_dir, options)
  File "scripts/mypy", line 80, in type_check_only
    python_path=options.python_path)
  File "/home/jukka/project/mypy/mypy/build.py", line 164, in build
    result = manager.process(UnprocessedFile(info, program_text))
  File "/home/jukka/project/mypy/mypy/build.py", line 341, in process
    next.process()
  File "/home/jukka/project/mypy/mypy/build.py", line 814, in process
    self.type_checker().visit_file(self.tree, self.tree.path)
  File "/home/jukka/project/mypy/mypy/checker.py", line 350, in visit_file
    self.accept(d)
  File "/home/jukka/project/mypy/mypy/checker.py", line 357, in accept
    typ = node.accept(self)
  File "/home/jukka/project/mypy/mypy/nodes.py", line 519, in accept
    return visitor.visit_expression_stmt(self)
  File "/home/jukka/project/mypy/mypy/checker.py", line 1302, in visit_expression_stmt
    self.accept(s.expr)
  File "/home/jukka/project/mypy/mypy/checker.py", line 357, in accept
    typ = node.accept(self)
  File "/home/jukka/project/mypy/mypy/nodes.py", line 938, in accept
    return visitor.visit_call_expr(self)
  File "/home/jukka/project/mypy/mypy/checker.py", line 1709, in visit_call_expr
    result = self.expr_checker.visit_call_expr(e)
  File "/home/jukka/project/mypy/mypy/checkexpr.py", line 118, in visit_call_expr
    return self.check_call_expr_with_callee_type(callee_type, e)
  File "/home/jukka/project/mypy/mypy/checkexpr.py", line 128, in check_call_expr_with_callee_type
    e.arg_names, callable_node=e.callee)[0]
  File "/home/jukka/project/mypy/mypy/checkexpr.py", line 171, in check_call
    callee, args, arg_kinds, formal_to_actual, context)
  File "/home/jukka/project/mypy/mypy/checkexpr.py", line 351, in infer_function_type_arguments
    callee_type, pass1_args, arg_kinds, formal_to_actual)  # type: List[Type]
  File "/home/jukka/project/mypy/mypy/infer.py", line 33, in infer_function_type_arguments
    return solve_constraints(type_vars, constraints)
  File "/home/jukka/project/mypy/mypy/solve.py", line 41, in solve_constraints
    bottom = join_types(bottom, c.target)
  File "/home/jukka/project/mypy/mypy/join.py", line 68, in join_types
    return t.accept(TypeJoinVisitor(s))
AttributeError: 'NoneType' object has no attribute 'accept'
@JukkaL JukkaL added bug mypy got something wrong priority labels May 15, 2015
@JukkaL JukkaL closed this as completed in 42b9328 May 15, 2015
JamesGuthrie pushed a commit to JamesGuthrie/mypy that referenced this issue May 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant