Skip to content

internal error with lambda (x): ... #1312

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

Closed
michal-au opened this issue Mar 22, 2016 · 6 comments
Closed

internal error with lambda (x): ... #1312

michal-au opened this issue Mar 22, 2016 · 6 comments
Assignees
Labels
bug mypy got something wrong

Comments

@michal-au
Copy link

test.py:
filter(lambda (x): x > 0, [0,1])

...$ mypy --py2 test.py 
Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 6, in <module>
    main(__file__)
  File "/usr/local/lib/python3.4/dist-packages/mypy/main.py", line 54, in main
    type_check_only(sources, bin_dir, options)
  File "/usr/local/lib/python3.4/dist-packages/mypy/main.py", line 98, in type_check_only
    python_path=options.python_path)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 206, in build
    result = manager.process(initial_states)
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 403, in process
    next.process()
  File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 907, in process
    self.type_checker().visit_file(self.tree, self.tree.path)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 406, in visit_file
    self.accept(d)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 447, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 540, in accept
    return visitor.visit_expression_stmt(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1534, in visit_expression_stmt
    self.accept(s.expr)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 447, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 965, in accept
    return visitor.visit_call_expr(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 1946, in visit_call_expr
    return self.expr_checker.visit_call_expr(e)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 142, in visit_call_expr
    return self.check_call_expr_with_callee_type(callee_type, e)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 193, in check_call_expr_with_callee_type
    e.arg_names, callable_node=e.callee)[0]
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 233, in check_call
    callee, args, arg_kinds, formal_to_actual, context)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 399, in infer_function_type_arguments
    callee_type, args, arg_kinds, formal_to_actual)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 328, in infer_arg_types_in_context2
    res[ai] = self.accept(args[ai], callee.arg_types[i])
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 1423, in accept
    return self.chk.accept(node, context)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 447, in accept
    typ = node.accept(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/nodes.py", line 1187, in accept
    return visitor.visit_func_expr(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 2071, in visit_func_expr
    return self.expr_checker.visit_func_expr(e)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checkexpr.py", line 1249, in visit_func_expr
    self.chk.check_func_item(e, type_override=inferred_type)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 620, in check_func_item
    self.check_func_def(defn, typ, name)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 717, in check_func_def
    self.accept_in_frame(item.body)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 463, in accept_in_frame
    changed, _ = self.binder.pop_frame(True, True)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 209, in pop_frame
    changed = self.update_from_options(options)
  File "/usr/local/lib/python3.4/dist-packages/mypy/checker.py", line 161, in update_from_options
    if not is_same_type(type, current_value):
  File "/usr/local/lib/python3.4/dist-packages/mypy/sametypes.py", line 27, in is_same_type
    return left.accept(SameTypeVisitor(right))
  File "/usr/local/lib/python3.4/dist-packages/mypy/types.py", line 157, in accept
    return visitor.visit_erased_type(self)
  File "/usr/local/lib/python3.4/dist-packages/mypy/sametypes.py", line 74, in visit_erased_type
    raise RuntimeError()
RuntimeError: 

*** INTERNAL ERROR ***

test.py:1: error: Internal error -- please report a bug at https://github.com/JukkaL/mypy/issues
@gvanrossum gvanrossum added the bug mypy got something wrong label Mar 22, 2016
@gvanrossum
Copy link
Member

Thanks for reporting this! It's almost certainly due to the way parameter unpacking treats this end case. Do you feel up to trying to come up with a fix yourself?

@michal-au
Copy link
Author

Sure, I can give it a try... We'll see what happens.

@gvanrossum gvanrossum added this to the 0.3.2 milestone Apr 7, 2016
@gvanrossum gvanrossum changed the title internal error with filter internal error with lambda (x): ... Apr 14, 2016
@gvanrossum
Copy link
Member

Reid, does this still feel like something you'd like to do? I can also take a look myself.

@rwbarton
Copy link
Contributor

I would be happy to have you look at it; actually I don't even know what lambda (x): ... is supposed to mean in the first place :)

@gvanrossum gvanrossum assigned gvanrossum and unassigned rwbarton Apr 14, 2016
@gvanrossum
Copy link
Member

OK. Quite possibly I assigned it to you by mistake.

FWIW lambda (x): ... is the same as lambda x: ... -- it's an edge case of lambda (x, y): ... which is Python 2 only syntax that requires a single argument that's a tuple of 2 values.

@gvanrossum
Copy link
Member

Closed by b4b0c1c (PR #1384).

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

3 participants