The following runtime error:
Output is too long but this is the main idea:
" > outer-scope error "
" > [File_fla::MainTimeline~[O] Object[A] Object[A] *[A] *[A]] {} ()"
previous line repeated for every abc bytecode: pushscope, subtract, multiply and convert_d etc.
" > VerifyError: Error #1023: Stack overflow occurred."
for this code:
import flash.geom.Point;
function d(p1:Object, p2:Object):Number
{
var dx:Number = p2.x - p1.x;
var dy:Number = p2.y - p1.y;
// problem here as adding this line solves it -> (dx *= 1;)
dy *= dy;
dy += dx;
return dy;
}
var pt1:Point = new Point(0, 0);
var pt2:Point = new Point(1, 0);
d(pt1, pt2);
I'm not interested in solving the error,
but knowing why it happens: an explanation from a knowledgeable user.
Speculation: I'm guessing it could be related to data hazard in pipelining (using dy before it is ready) as adding the commented line above solves it.
EDIT: This image shows the decompiling of swfs for a slight code variant and a debug mode swf (pinpointed by Daniel in the comments)
http://imageshack.us/a/img853/4057/stackoverflowdecompile.jpg
If the source of the problem was located correctly, the question becomes why is the function at consecutive ‘dup’ calls entering an infinite loop causing the stack to overflow?