views:

460

answers:

3

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());
      } 
}
+2  A: 

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());
Andy Li
You're right ,this does work. But after some testing, it still doesn't explain why the problem happens. See my latest edit to the question.
Glenn
Interesting... I think Amarghosh is correct that there is some problem with the compiler. I'm now testing on Flex 4 SDK, tell you the result soon to see if we really need to report a bug.
Andy Li
Reproduced in Flex SDK 3.4 and 4.0.0.6898. Filled the bug at https://bugs.adobe.com/jira/browse/ASC-3844
Andy Li
Going to accept this one because you had the first workaround and logged the bug. Cheers for that.
Glenn
+2  A: 

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

Amarghosh
I think you meant this link: http://livedocs.adobe.com/flex/2/langref/runtimeErrors.html#note. The one you posted has no errors < 2000, but it does mention to look at the Flex 2 runtimes errors. Thanks.
Glenn
Yeah, thanks for correcting.
Amarghosh
Does this work? o.ids = (o.ids ? o.ids : []).concat(getArray());
Amarghosh
A: 

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/

Jonathon Stierman