Upgraded to Unity3 - receiving VerificationException - Binary instruction applyed to ill formed stack - Help!

For the life of me, I can't figure out why I'm receiving this runtime exception. I've just upgraded to Unity3 Pro from 2.6 on the Mac and am porting over our game to Unity v3 and are receiving this runtime exception:

VerificationException: Error verifying GameScript:SetGameState (eGameState): Binary instruction applyed to ill formed stack (Complex x Complex)
GameScript.Start () (at Assets/Scripts/GameScript.js:100)

The problem is related to one of our game files.

  1. We declare at the top of the file an enum called eGameState.

    enum eGameState { Start=0, LevelComplete=1, LevelStart=2, Playing=3, GameOver=4, LoadMainMenu= 5, Restart = 6 };

    var gGameState : eGameState = eGameState.Start;

  2. We have a function called SetGameState defined as follows:

    function SetGameState( theState:eGameState ) { var oldGameState:eGameState;

    oldGameState= gGameState;
    
    // update game state to new one
    gGameState= theState;
    
    

    .. more code...

    }

  3. We call SetGameState() function from this file and other files as follows..

    function Start() { // code...

    SetGameState( eGameState.LevelStart );
    
    

    }

  4. Everything compiles fine.. when running receive this runtime exception What the heck are we doing wrong (or what has changed in Unity3 to cause this to be a problem?

    VerificationException: Error verifying GameScript:SetGameState (eGameState): Binary instruction applyed to ill formed stack (Complex x Complex) GameScript.Start () (at Assets/Scripts/GameScript.js:100)

Turns out that references to some of my prefabs when imported into Unity3d v3 (from my 2.6 project) were set to null. When the code referenced/tried instantiating the objects at runtime - it threw the ambiguous exception above that was referencing the wrong section/line of code entirely -making it difficult to identify the real problem.

I have since put in checks to make sure my prefab's aren't NULL (should have done that in the beginning). Anyways' this was a difficult to figure out.. but well.. it's working again.

Hey Shiraz,

This error is not related to your prefab problem (allthough fixing your prefab problem might make this bug go away). This looks like a legit bug in Unity3 that I would love to fix. Could you send the project that makes this happen in a bugreport, and mention the casenumber here? (UnityMenu->Help->Report a problem). Thanks a lot!, Lucas