// Test declarations of identifiers in the correct scope

// Invalid Redeclations in same scope
var a;
function a() return 1; end;

function f1(d) var d; return 1; end; // redeclaration of d caught here with static scoping
f1(1);                                  // and caught here with dynamic scoping

function f2() var p; var p; return 2; end;  // redeclaration of p caught here with static scoping
f2();                                  // redeclaration of p caught here with dynamic scoping

//Trying to use an identifier defined in the wrong scope
function g1() var i; return 3; end;  // no error on this line
function g2() i = 0; return 4; end;  // undeclared i caught here with static scoping
g2();                               // inactive i caught here with dynamic scoping