aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2020-09-09 22:47:47 +0200
committerArmin Rigo <arigo@tunes.org>2020-09-09 22:47:47 +0200
commit986d01ff5df9b167c3a0c35de1c266797ce1df25 (patch)
treec635c685a2998c2b72895ad3cbd8fa25d3e0048b
parentA fix for a corner case (shown by test_ztranslation in branch 'hpy'). (diff)
downloadpypy-986d01ff5df9b167c3a0c35de1c266797ce1df25.tar.gz
pypy-986d01ff5df9b167c3a0c35de1c266797ce1df25.tar.bz2
pypy-986d01ff5df9b167c3a0c35de1c266797ce1df25.zip
next similar issue (73e7c4e0b67d)
-rw-r--r--rpython/rtyper/rpbc.py7
-rw-r--r--rpython/rtyper/test/test_rpbc.py24
2 files changed, 31 insertions, 0 deletions
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
index 9eedd150f1..c4344afa61 100644
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -823,6 +823,13 @@ class __extend__(pairtype(FunctionRepr, MultipleFrozenPBCRepr)):
return Constant(value, lltype)
return NotImplemented
+class __extend__(pairtype(MultipleFrozenPBCRepr, FunctionRepr)):
+ def convert_from_to((r_frozen1, r_fn2), v, llops):
+ if r_fn2.lowleveltype is Void:
+ value = r_fn2.s_pbc.const
+ return Constant(value, Void)
+ return NotImplemented
+
class MethodOfFrozenPBCRepr(Repr):
"""Representation selected for a PBC of method object(s) of frozen PBCs.
diff --git a/rpython/rtyper/test/test_rpbc.py b/rpython/rtyper/test/test_rpbc.py
index fbabea0107..fcc3a01781 100644
--- a/rpython/rtyper/test/test_rpbc.py
+++ b/rpython/rtyper/test/test_rpbc.py
@@ -1815,6 +1815,30 @@ class TestRPBC(BaseRtypingTest):
return h3
self.interpret(g, [-5])
+ def test_single_function_from_noncallable_pbcs(self):
+ from rpython.annotator import annrpython
+ a = annrpython.RPythonAnnotator()
+
+ def h1(i):
+ return i + 5
+ def h3(i):
+ "NOT_RPYTHON" # should not be annotated
+ return i + 7
+
+ def other_func(i):
+ h1(i)
+ return h1
+
+ def g(i):
+ if i & 1:
+ fn = h1
+ else:
+ fn = h3
+ h1(i)
+ if fn is h1:
+ fn(i)
+ self.interpret(g, [-5])
+
# ____________________________________________________________
def test_hlinvoke_simple():