[Mono-list] Bug in mcs: casting type enum to integral type

Adam Treat manyoso@yahoo.com
Mon, 25 Feb 2002 20:59:35 -0800


Hi all,

Noticed another bug in the compiler.  mcs is having trouble compiling classes 
with explicit casting of type enum to one of the integral types.  The 
following test outlines the error.  The error I recieve is:

Unhandled exception System.NullReferenceException A null value was found 
where an object instance was required.
#0: 0x00001 callvirt   in Mono.CSharp.Expression::ConvertNumericExplicit 
([0x81d0a58] [(nil)] [0x80ecd38] )
#1: 0x0007e call       in Mono.CSharp.Expression::ConvertExplicit 
([0x81d0a58] [0x81e1cf0] [0x80ecd38] [vt: 0xbfffddec] )

Cheers,

Adam

============================================================

//
// Tests enums and explicit casts of type enum.
//

using System;

public enum foo:uint {
	a = 0,
	b = 1
}

public class Blah {

	static void Main() {
		Console.WriteLine((int)foo.a + "This doesn't work.");
		Console.WriteLine((uint)foo.b + "This works.");
	}
}