Glenn
Glenn

Reputation: 5342

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());
      } 
}

Upvotes: 3

Views: 2253

Answers (3)

Jonathon Stierman
Jonathon Stierman

Reputation: 1

I've received this error when creating local variables named "arguments" within a function as well. The compiler doesn't give any warnings, and I've sometimes gotten away with it -- only to have the error pop back up after adding a couple lines. The console gives the crazy error stack, and doesn't let you use the FB debugger in any useful fashion when the error occurs. This happens due to a conflict with the standard "arguments" object available from within any function:

http://as3.miguelmoraleda.com/2009/03/28/actionscript-3-arguments-atributo-arguments-dentro-de-cualquier-funcion-functio/

Upvotes: 0

Amarghosh
Amarghosh

Reputation: 59451

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

Upvotes: 2

Andy Li
Andy Li

Reputation: 6034

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());

Upvotes: 2

Related Questions