Commits

Greg Price  committed 10e68c1 Draft

Test list types in signatures are immutable

  • Participants
  • Parent commits 4e1c1d0
  • Branches signatures

Comments (0)

Files changed (1)

File pypy/rlib/test/test_objectmodel.py

     def bad_for_body():
         f('a')
 
+    @signature(returns=types.list(types.char()))
+    def ff():
+        return ['a']
+    @check_annotator_fails
+    def mutate_broader():
+        ff()[0] = 'abc'
+    @check_annotator_fails
+    def mutate_unrelated():
+        ff()[0] = 1
+    @check_annotator_fails
+    @signature(types.list(types.char()), returns=types.int())
+    def mutate_in_body(l):
+        l[0] = 'abc'
+        return len(l)
+
+
 
 def getgraph(f, argtypes):
     from pypy.translator.translator import TranslationContext, graphof