add safety check for cross-closure type inference
authorStefan Behnel <stefan_ml@behnel.de>
Sun, 23 Dec 2012 19:02:00 +0000 (20:02 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sun, 23 Dec 2012 19:02:00 +0000 (20:02 +0100)
Cython/Compiler/TypeInference.py

index 9b7af1d..4164802 100644 (file)
@@ -401,7 +401,13 @@ class SimpleAssignmentTypeInferer(object):
                     entry_type = py_object_type
                 # propagate entry type to all nested scopes
                 for e in entry.all_entries():
-                    e.type = entry_type
+                    if e.type is unspecified_type:
+                        e.type = entry_type
+                    else:
+                        # FIXME: can this actually happen?
+                        assert e.type == entry_type, (
+                            'unexpected type mismatch between closures for inferred type %s: %s vs. %s' %
+                            entry_type, e, entry)
                 if verbose:
                     message(entry.pos, "inferred '%s' to be of type '%s'" % (entry.name, entry.type))
                 resolve_dependancy(entry)