Author: Armin Rigo <[email protected]>
Branch:
Changeset: r72626:372fd1f54b6d
Date: 2014-07-31 17:08 +0200
http://bitbucket.org/pypy/pypy/changeset/372fd1f54b6d/
Log: Expand a failing AssertionError with a more descriptive TyperError.
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -93,7 +93,12 @@
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
diff --git a/rpython/rtyper/test/test_normalizecalls.py
b/rpython/rtyper/test/test_normalizecalls.py
--- a/rpython/rtyper/test/test_normalizecalls.py
+++ b/rpython/rtyper/test/test_normalizecalls.py
@@ -192,6 +192,25 @@
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()
+ else:
+ s = Sub2()
+ return s.fn(*(n,))
+
+ py.test.raises(TyperError, self.rtype, dummyfn, [int], int)
+
class PBase:
def fn(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit