[Mono-list] Help needed: C# SimpleNames and MemberAccess
Miguel de Icaza
miguel@ximian.com
23 Dec 2001 21:58:19 -0500
Hey guys,
I am in need of help. I have been reading the sections on "Simple
Names" and "Member Access" over and over and I can not understand why
this program can be compiled correctly. My reading of the spec is that
this is an invalid program (as mcs flags it), but csc generates code
that does what you would expect it to do:
class Location {
static public int Null {
get {
return 1;
}
}
}
class X {
Location Location;
X ()
{
int a = Location.Null;
}
static void Main () {}
}
Few things to notice:
* Null is a static property of class Location.
* X is an instance method
* Location Location is an instance variable.
My reading of Simple Names says that the `Location' in Location.Null
matches an instance member, so the result should be this.Location. Then
the Member Access on Null would catch the error.
Now, if I change the code there to have an explicit 'this' then CSC
behaves just like MCS, but this is not what the spec states.
I am assuming I am miss-reading the spec here.
miguel.