Phillip J. Eby wrote: > And for the case where the compiler can tell the variable is accessed > before it's defined, there's definitely something wrong. This code, for > example, is definitely missing a "global" and the compiler could in > principle tell: > > foo = 1 > > def bar(): > foo+=1 > > So I see no problem (in principle, as opposed to implementation) with > issuing a warning or even a compilation error for that code. (And it's > wrong even if the snippet I showed is in a nested function definition, > although the error would be different.) > > If I recall correctly, the new compiler uses a control-flow graph that > could possibly be used to determine whether there is a path on which a > local could be read before it's stored.
I think symtable.c could wander back up the lexical block stack checking that target names are defined for augmented assignment statements. That said, while I'd be happy to review a patch, I'm not going to try to write one :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com