From: Robert Bradshaw Date: Sun, 30 Mar 2008 10:26:32 +0000 (-0700) Subject: Fix enum bug (values weren't forced to ints) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4c48e8d42091d314cd35601c1eeb555cf13abde3;p=cython.git Fix enum bug (values weren't forced to ints) --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 8515688c..25e3a53a 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 1a3cca71..e8624d15 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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