Here's the addition of a test case.

I added a visit_ReturnStatNode in PostParse (not in the patch below),
but it seems there is some issue with error handling.  If I raise a
PostParseError, everything is fine and the compiler stops there.  But
when there are multiple tests in the test case (see below) the later
errors (3:4 and 6:4) aren't tested.  It seems that the best route is
to call the error(pos, message) function and have it record the
errors; this works for other stages in the pipeline
(AnalyseDeclarationsTransform, e.g.) but fails at the PostParse stage
(the compiler barfs).

I reckon something like a standardized error reporting/handling would
be a good thing to do, but I'm not sure why the current error handling
is in place.  PostParse raises PostParseError which will stop the
compiler in its tracks, while other stages call error() to allow all
errors to be reported after the pipeline is run.


# HG changeset patch
# User Kurt Smith <[email protected]>
# Date 1237857818 18000
# Node ID 346d8d3955293edb37498231d76799f0926c561a
# Parent  e2365a6d00b8d0cdb665699e840a8f052d471e37
Added test case for ticket 135 in tests/bugs.

diff -r e2365a6d00b8 -r 346d8d395529 tests/bugs/return_outside_function_T135.pyx
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bugs/return_outside_function_T135.pyx       Mon Mar 23
20:23:38 2009 -0500
@@ -0,0 +1,12 @@
+return 'bar'
+class A:
+    return None
+
+cdef class B:
+    return None
+
+_ERRORS = u'''
+1:0: Return not inside a function body
+3:4: Return not inside a function body
+6:4: Return not inside a function body
+'''
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to