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): ...@@ -93,7 +93,12 @@ def normalize_calltable_row_signature(annotator, shape, row):
return False # nothing to do, all signatures already match return False # nothing to do, all signatures already match
shape_cnt, shape_keys, shape_star = shape 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 # for the first 'shape_cnt' arguments we need to generalize to
# a common type # a common type
......
...@@ -192,6 +192,25 @@ the callers of these functions are: ...@@ -192,6 +192,25 @@ the callers of these functions are:
import re import re
assert re.match(msg, excinfo.value.args[0]) 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()
else:
s = Sub2()
return s.fn(*(n,))
py.test.raises(TyperError, self.rtype, dummyfn, [int], int)
class PBase: class PBase:
def fn(self): def fn(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment