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

arigo at codespeak.net arigo at codespeak.net
Thu May 12 13:42:06 CEST 2005


Author: arigo
Date: Thu May 12 13:42:06 2005
New Revision: 12213

Modified:
   pypy/dist/pypy/rpython/lltypes.py
   pypy/dist/pypy/rpython/test/test_lltypes.py
Log:
Check that we don't try to inline a var-sized struct in another struct.


Modified: pypy/dist/pypy/rpython/lltypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypes.py	(original)
+++ pypy/dist/pypy/rpython/lltypes.py	Thu May 12 13:42:06 2005
@@ -52,6 +52,9 @@
             if name in flds:
                 raise TypeError("%s: repeated field name" % self._name)
             flds[name] = typ
+            if isinstance(typ, Struct) and typ._arrayfld:
+                raise TypeError("cannot inline a var-sized struct "
+                                "inside another struct")
         # look if we have an inlined variable-sized array as the last field
         if fields:
             for name, typ in fields[:-1]:

Modified: pypy/dist/pypy/rpython/test/test_lltypes.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_lltypes.py	(original)
+++ pypy/dist/pypy/rpython/test/test_lltypes.py	Thu May 12 13:42:06 2005
@@ -105,6 +105,7 @@
     assert s1.rest[3].v == 5
 
     py.test.raises(TypeError, "Struct('invalid', ('rest', Array(('v', Signed))), ('a', Signed))")
+    py.test.raises(TypeError, "Struct('invalid', ('x', S1))")
 
 def test_substructure_ptr():
     S2 = Struct("s2", ('a', Signed))



More information about the Pypy-commit mailing list