Thursday, September 11, 2014

FIXED: VerifyError: Error #1068: int and * cannot be reconciled

//THIS SIMPLE CODE WILL CAUSE A STACK DUMP IN AS3:
//[Fault] exception, information=VerifyError: Error #1068: int and * cannot be reconciled.
private static function stackDump():void
{ 
 //obj can be an object, dictionary, vector, array.
 //probably anything that can be accessed using bracket notation.
 var obj:Array = [1, 2];
 var dex:int = 0;

 //if you access an object,vector,array,or dictionary using a nested incrimentor operator
 //followed by a continue statement, you will get a stack dump.
 //The loop can be a for, while, or do loop.
 while (false)
  {
  obj[dex++] = 0;
  continue;
  }

}//end stackDump


How do you fix it?
The problem is caused by using a continue statement after accessing an object using a nested increment operator on a variable.
Change the code inside the loop to:

dex++;
obj[dex] = 0;
continue;

OR:

obj[dex] = 0;
dex++;
continue;


Whichever one has the logic you are going for.


private static function stackDumpFIXED():void
{ 
 //obj can be an object, dictionary, vector, array.
 //probably anything that can be accessed using bracket notation.
 var obj:Array = [1, 2];
 var dex:int = 0;

 //if you access an object,vector,array,or dictionary using a nested incrimentor operator
 //followed by a continue statement, you will get a stack dump.
 //The loop can be a for, while, or do loop.
 while (false)
 {
  dex++;
                obj[dex] = 0;
                continue;
 }

}//end stackDump

2 comments:

  1. Note: Happens in flash player 10.1.
    Pretty sure it does not happen in newer versions of flash player, but you'd be amazed at how many people are using
    older versions of flash.
    Because of this, I need to code around this bug.

    ReplyDelete
  2. Alternate solution, if you can't fix the incriment, getting rid of the continue statement by making this hack could help:

    private static function stackDumpFIXED02():void
    {
    //obj can be an object, dictionary, vector, array.
    //probably anything that can be accessed using bracket notation.
    var obj:Array = [1, 2];
    var dex:int = 0;

    //if you access an object,vector,array,or dictionary using a nested incrimentor operator
    //followed by a continue statement, you will get a stack dump.
    //The loop can be a for, while, or do loop.
    while (false)
    {
    if (true)
    {
    obj[dex++] = 0;
    break; //<<HACK: use break as a continue statement by putting all of your logic into an if(true) block.
    }

    }
    }

    ReplyDelete