fix C name redefinition: names must be uniquified at the module scope, local scope...
authorStefan Behnel <scoder@users.berlios.de>
Sat, 22 Jan 2011 16:10:30 +0000 (17:10 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 22 Jan 2011 16:10:30 +0000 (17:10 +0100)
Cython/Compiler/Symtab.py

index 536cb72e441d8cb99df1af47de6d945987e37956..74a80eb834111c1cae2cf1af1d3c47cf95a03351 100644 (file)
@@ -306,13 +306,17 @@ class Scope(object):
         #return self.parent_scope.mangle(prefix, self.name)
 
     def next_id(self, name=None):
-        # Return a cname fragment that is unique for this scope.
+        # Return a cname fragment that is unique for this module
+        counters = self.global_scope().id_counters
         try:
-            count = self.id_counters[name] + 1
+            count = counters[name] + 1
         except KeyError:
             count = 0
-        self.id_counters[name] = count
+        counters[name] = count
         if name:
+            if not count:
+                # unique names don't need a suffix, reoccurrences will get one
+                return name
             return '%s%d' % (name, count)
         else:
             return '%d' % count