[pypy-svn] r12870 - in pypy/dist/pypy/rpython: . test

arigo at codespeak.net arigo at codespeak.net
Sun May 29 19:40:45 CEST 2005


Author: arigo
Date: Sun May 29 19:40:45 2005
New Revision: 12870

Modified:
   pypy/dist/pypy/rpython/rtyper.py
   pypy/dist/pypy/rpython/test/test_rtyper.py
Log:
Constants along links not properly typed.
A fix and a test.


Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py	(original)
+++ pypy/dist/pypy/rpython/rtyper.py	Sun May 29 19:40:45 2005
@@ -86,8 +86,11 @@
                     ##if a1 in (link.last_exception, link.last_exc_value):# treated specially in gen_link
                     ##    continue
                     a2 = link.target.inputargs[i]
-                    s_a1 = self.annotator.binding(a1)
                     s_a2 = self.annotator.binding(a2)
+                    if isinstance(a1, Constant):
+                        link.args[i] = inputconst(s_a2.lowleveltype(), a1.value)
+                        continue   # the Constant was typed, done
+                    s_a1 = self.annotator.binding(a1)
                     if s_a1 == s_a2:
                         continue   # no conversion needed
                     newops = LowLevelOpList(self)
@@ -269,6 +272,7 @@
         self.rtyper = rtyper
 
     def convertvar(self, v, s_from, s_to):
+        assert isinstance(v, Variable)
         if s_from != s_to:
             v = pair(s_from, s_to).rtype_convert_from_to(v, self)
             if v is NotImplemented:

Modified: pypy/dist/pypy/rpython/test/test_rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rtyper.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rtyper.py	Sun May 29 19:40:45 2005
@@ -27,3 +27,30 @@
     typer.specialize()
     #t.view()
     t.checkgraphs()
+
+
+def test_retval():
+    def f(x):
+        return x
+    t = Translator(f)
+    t.annotate([int])
+    typer = RPythonTyper(t.annotator)
+    typer.specialize()
+    #t.view()
+    t.checkgraphs()
+    graph = t.getflowgraph(f)
+    assert graph.getreturnvar().concretetype == Signed
+    assert graph.startblock.exits[0].args[0].concretetype == Signed
+
+def test_retval_None():
+    def f(x):
+        pass
+    t = Translator(f)
+    t.annotate([int])
+    typer = RPythonTyper(t.annotator)
+    typer.specialize()
+    #t.view()
+    t.checkgraphs()
+    graph = t.getflowgraph(f)
+    assert graph.getreturnvar().concretetype == Void
+    assert graph.startblock.exits[0].args[0].concretetype == Void



More information about the Pypy-commit mailing list