Fix enum bug (values weren't forced to ints)
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 30 Mar 2008 10:26:32 +0000 (03:26 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 30 Mar 2008 10:26:32 +0000 (03:26 -0700)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Nodes.py

index 8515688cf0535d5660b5471c81f448025ec26ab5..25e3a53a8e0fb8e513d82e2fef548b6bed9b39cc 100644 (file)
@@ -947,7 +947,8 @@ class NameNode(AtomicExprNode):
                     namespace, 
                     self.entry.name,
                     code.error_goto_if_null(self.result_code, self.pos)))
-        elif entry.is_local:
+        elif entry.is_local and False:
+            # control flow not good enough yet
             assigned = entry.scope.control_flow.get_state((entry.name, 'initalized'), self.pos)
             if assigned is False:
                 error(self.pos, "local variable '%s' referenced before assignment" % entry.name)
index 1a3cca71a41d2169d422978d9309e4889345abe7..e8624d15e47686be2e965157bfe345b74aa4608e 100644 (file)
@@ -728,6 +728,9 @@ class CEnumDefItemNode(StatNode):
     def analyse_declarations(self, env, enum_entry):
         if self.value:
             self.value.analyse_const_expression(env)
+            if not self.value.type.is_int:
+                self.value = self.value.coerce_to(PyrexTypes.c_int_type, env)
+                self.value.analyse_const_expression(env)
             value = self.value.result_code
         else:
             value = self.name