enable type inference in generators (but keep it disabled for variables in other...
authorStefan Behnel <scoder@users.berlios.de>
Thu, 7 Apr 2011 11:26:11 +0000 (13:26 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 7 Apr 2011 11:26:11 +0000 (13:26 +0200)
Cython/Compiler/TypeInference.py
tests/bugs.txt

index 04c39dab6eeda8a8a7fa9c09090d38a4f2721ad2..e1fd9df22e898e772189e7543ab863f2057c2524 100644 (file)
@@ -221,9 +221,9 @@ class SimpleAssignmentTypeInferer(object):
     # TODO: Implement a real type inference algorithm.
     # (Something more powerful than just extending this one...)
     def infer_types(self, scope):
-        closure_or_inner = scope.is_closure_scope or (scope.outer_scope and scope.outer_scope.is_closure_scope)
-        enabled = not closure_or_inner and scope.directives['infer_types']
+        enabled = scope.directives['infer_types']
         verbose = scope.directives['infer_types.verbose']
+
         if enabled == True:
             spanning_type = aggressive_spanning_type
         elif enabled is None: # safe mode
@@ -239,6 +239,10 @@ class SimpleAssignmentTypeInferer(object):
         ready_to_infer = []
         for name, entry in scope.entries.items():
             if entry.type is unspecified_type:
+                if entry.in_closure:
+                    # cross-closure type inference is not currently supported
+                    entry.type = py_object_type
+                    continue
                 all = set()
                 for expr in entry.assignments:
                     all.update(expr.type_dependencies(scope))
index f1478a3bccccece35484b3666706cfb69394c4d6..c8845007f082d382ac7a4097db9fa98368710d98 100644 (file)
@@ -18,7 +18,6 @@ genexpr_iterable_lookup_T600
 for_from_pyvar_loop_T601
 decorators_T593
 temp_sideeffects_T654
-generator_type_inference
 
 # CPython regression tests that don't current work:
 pyregr.test_threadsignals