Strange / dangerous(?) bug with function optional arguments

function:
function testfunc( p1, p2, o1, o2 )
{
var v1 = 5;
var v2 = 6;

Sys.println( " ---- " + p1 + " ; " + p2 + " ; " + o1 + " ; " + o2 + " ; " + v1 + " ; " + v2 + " ---- ");
}


call1:
testfunc(1, 2, 3, 4);

Output: " ---- 1 ; 2 ; 3 ; 4 ; 5 ; 6 ---- "

call2:
testfunc(1, 2);

Output: " ---- 1 ; 2 ; null ; null ; 5 ; ---- "

In second case, with calling testfunc() without all arguments, it damage the variable value inside the function. The value of v2 is not 6!

I test it only in Simulator, not at a real device.