Commit 71ecc360 authored by Armin Rigo's avatar Armin Rigo

Expand a failing AssertionError with a more descriptive TyperError.

parent ec35811f
......@@ -93,7 +93,12 @@ def normalize_calltable_row_signature(annotator, shape, row):
return False # nothing to do, all signatures already match
shape_cnt, shape_keys, shape_star = shape
assert not shape_star, "XXX not implemented"
if shape_star:
raise TyperError(
"not implemented: a call is done with a '*' argument, and the"
" multiple functions or methods that it can go to don't have"
" all the same signature (different argument names or defaults)."
" The call can go to:\n%s" % '\n'.join(map(repr, graphs)))
# for the first 'shape_cnt' arguments we need to generalize to
# a common type
......@@ -192,6 +192,25 @@ the callers of these functions are:
import re
assert re.match(msg, excinfo.value.args[0])
def test_methods_with_named_arg_call(self):
class Base:
def fn(self, y):
raise NotImplementedError
class Sub1(Base):
def fn(self, y):
return 1 + y
class Sub2(Base):
def fn(self, x): # different name!
return x - 2
def dummyfn(n):
if n == 1:
s = Sub1()
s = Sub2()
return s.fn(*(n,))
py.test.raises(TyperError, self.rtype, dummyfn, [int], int)
class PBase:
def fn(self):
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment