Comparing enums and ints (javascript)

Why does this work:

var _mode : int;

_mode = manager.gameMode;

if (_mode == mode.editSetup) {
	//do some stuff	
}

But not this:

if (manager.gameMode == mode.editSetup) {
	//do some stuff	
}

The compiler insists that manager.gameMode is an Object, even though it is declared this way (in another script):

var gameMode : int = 0;

mode is an enum, and the compiler is clearly treating it as int in this case (it complains that I’m trying to compare an Object to an int). The manager script has other vars in it that I reference without any problem. Why would the compiler think that this particular var reference is an object and not an int?

The following script works for me:

/* define a test enum */

enum TestEnum { Funky, Nifty, Super }

/* define a public var of type TestClass */

public var theTestObject : TestClass;

/* define TestClass */

class TestClass
{
	public var theMember : TestEnum;
}

/* test it */

function OnGUI ()
{    
	var theLabel : String;

	if ( theTestObject.theMember == TestEnum.Funky ) {
		theLabel = "Quite Funky";
	}

	else {
		theLabel = "Not so Funky";
	}

	var theRect : Rect = Rect(200, 200, 200, 50);

	GUI.Label(theRect, theLabel);
}

Isn’t that the same thing that isn’t working for you in your second example?