[IronPython] Compiler error for invalid field access

Chip Norkus wd at teleri.net
Sun Aug 5 21:57:55 CEST 2007

On Sun Aug 05, 2007; 12:51PM -0700, Ori wrote:
> Hello,
> I'm using the following code to compile python code:
> SystemState state = new SystemState();
> MyCompilerSink sink = new MyCompilerSink();
> CompilerContext context = new CompilerContext(string.Empty, sink);
> Parser parser = Parser.FromString(state, context, "my code");
> parser.ParseFileInput();
> it works find for finding syntax mistakes - but I also wan to know about
> invalid property names / method names. If for example the code uses the
> expression 'self.Name' I would like to see a compilation error if the object
> does not have a 'Name' property.

Because objects are mutable Python by its nature does not resolve
member/property references until they occur within the code.  Consider
the following example (which is valid functional Python):

class foo(object):
    setup = False

f = foo()

def bar(f):
    if f.setup:
        f.baz = "hi"
        print f.baz
        f.setup = True
        print "setup"


> Is there a way to do it?
> Thanks,
> Ori
> -- 
> View this message in context: http://www.nabble.com/Compiler-error-for-invalid-field-access-tf4220967.html#a12007623
> Sent from the IronPython mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
personal: chip norkus; irc: wd;                   wd at teleri.net
info:     finger wd at teleri.net for plan or keys;  http://telekinesis.org

More information about the Ironpython-users mailing list