Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionscript Compiler Problem: Error #1068: Array and * cannot be reconciled

I'm getting a very bizarre callstack in my Flex project (AS3).

Main Thread (Suspended: 
         VerifyError: Error #1068: Array and * cannot be reconciled.)

I was able to reproduce it using this block of code. If you debug, you'll never get inside "failure" function.

private var testArray:Array = [{},{},{}]

private function run():void {
  this.failure({});
}

private function failure(o:Object):void {
  for each(var el:Object in testArray) {
    o.ids = (o.ids||[]).concat(getArray());
  } 
}

private function getArray():Array {  return [Math.random()]; } 

When I run the program, this callstack is one line, but this conole shows a big mess as if it were a segmentation fault:

> verify monkeyTest/failure()
>                         stack:
>                         scope: [global Object$ flash.events::EventDispatcher$
> flash.display::DisplayObject$
> flash.display::InteractiveObject$
> flash.display::DisplayObjectContainer$
> flash.display::Sprite$
> mx.core::FlexSprite$
> mx.core::UIComponent$
> mx.core::Container$
> mx.core::LayoutContainer$
> mx.core::Application$ monkeyTest$] 
>                          locals: monkeyTest Object? * * *   

Any suggestions? Cheers.

EDIT:

This code does not produce the error:

private function failure(o:Object):void {
      for each(var el:Object in testArray) {
        o.ids = o.ids || [];
        o.ids = o.ids.concat(getArray());
      } 
}
like image 754
Glenn Avatar asked Dec 04 '25 17:12

Glenn


2 Answers

The problem is here:

o.ids = (o.ids||[]).concat(getArray());

o.ids is type * while [] is Array, so they can't be compared

Change it to:

o.ids = ((o.ids as Array)||[]).concat(getArray());
like image 65
Andy Li Avatar answered Dec 07 '25 05:12

Andy Li


This error indicates that the ActionScript in the SWF is invalid. If you believe that the file has not been corrupted, please report the problem to Adobe. (see the note at the bottom of that page).

Most verify errors are compiler errors that the compiler failed to capture. Reporting will help to fix them in the next version.

EDIT: Corrected the link, thanks Glenn

like image 27
Amarghosh Avatar answered Dec 07 '25 05:12

Amarghosh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!