Nicer error message for undeclared[idx]
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Mon, 26 Oct 2009 11:56:23 +0000 (12:56 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Mon, 26 Oct 2009 11:56:23 +0000 (12:56 +0100)
Cython/Compiler/ExprNodes.py

index ce0a6f2e3ba816728fb8f9599f489d2885ac8508..2dcecf2e16e0e3473e164f4c4bb278c5ffee6a55 100644 (file)
@@ -1787,6 +1787,12 @@ class IndexNode(ExprNode):
         self.is_buffer_access = False
 
         self.base.analyse_types(env)
+        if self.base.type.is_error:
+            # Do not visit child tree if base is undeclared to avoid confusing
+            # error messages
+            self.type = PyrexTypes.error_type
+            return
+        
         # Handle the case where base is a literal char* (and we expect a string, not an int)
         if isinstance(self.base, BytesNode):
             self.base = self.base.coerce_to_pyobject(env)