array size must be set as int, not numeric string
authorStefan Behnel <scoder@users.berlios.de>
Fri, 14 Nov 2008 18:19:55 +0000 (19:19 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 14 Nov 2008 18:19:55 +0000 (19:19 +0100)
Cython/Compiler/Nodes.py
Cython/Compiler/PyrexTypes.py

index 99c455e74a4715ef6a2b5793d4e7e7765ea05d79..56b69d8f2f409e2a99b194f07015239e9f417472 100644 (file)
@@ -442,6 +442,11 @@ class CArrayDeclaratorNode(CDeclaratorNode):
             if not self.dimension.type.is_int:
                 error(self.dimension.pos, "Array dimension not integer")
             size = self.dimension.result()
+            try:
+                size = int(size)
+            except ValueError:
+                # runtime constant?
+                pass
         else:
             size = None
         if not base_type.is_complete():
index 70330959b791d365cb3d93b59f44cce11705bed3..281cf0ad913096958ac941c690f7633c9c589fe0 100644 (file)
@@ -616,6 +616,7 @@ class CArrayType(CType):
     is_array = 1
     
     def __init__(self, base_type, size):
+        assert size is None or isinstance(size, int), repr(size)
         self.base_type = base_type
         self.size = size
         if base_type is c_char_type: