[Note: compiler-sig added to Cc list] On Wed, Oct 19, 2005 at 01:00:08PM -0600, Neil Schemenauer wrote: > On Wed, Oct 19, 2005 at 11:28:06AM -0400, Jeremy Hylton wrote: > > test_02_arigo (__main__.TraceTestCase) ... FAIL > > This one fails because the new compiler does dead code elimination > for "while 0" but not for "if 0". I've added optimization for "if > 0" and disabled the "while 0" optimization for now.
Oops, the "if 0" optimization is tricker than I thought. The new compiler needs something like look_for_offending_return() to detect illegal "return" statements inside generator functions. It's harder to do in the new compiler because nodes cannot be treated generically (the look_for_offending_return() is pretty simple and just self recurses). This check needs to be done after the symtable does its pass (symtable_visit_expr and friends). I wonder if it would be a good idea to add another general pass that runs between the symtable building and the code generation. Initially it would only check for illegal return statements but if we wanted to add pychecker type stuff in the future then that would seem to be the place to do it. Am I making this more complicated then it needs to be? Maybe I'm missing some easy way to write a look_for_offending_return() equivalent. Neil _______________________________________________ Compiler-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/compiler-sig
