Description:
If the catch parameter name in a function is the same as a global
variable, and both exist in a <%%> code block, then code will fail to
compile unless compiling with debug switch turned on.
Repro:
1. save test_fail.aspx (below) to a website with ASP.NET v2.0.50727
installed and set to "allowed"
2. browse to test_fail.aspx in a browser
3. Alternatively, compile the website from the command
line...something like this:
aspnet_compiler -f -fixednames-errorstack -v /LM/w3svc/4/ROOT d:\tmp
4. Notice the following compilation error:
Compiler Error Message: The compiler failed with error code 10.
Notice that test_success.aspx (below) compiles successfully...because
the catch parameter name is declared within the function, prior to the
close of the catch block...
Notice that the test_fail.aspx case actually works if debug is enabled
in the web.config file:
<compilation debug="true">
Alternatively, compile it from the command line passing in the debug (-
d) flag:
aspnet_compiler -d -f -fixednames-errorstack -v /LM/w3svc/4/ROOT d:
\tmp
-- BEGIN PAGE test_fail.aspx--
<%@Page Language="JScript"%>
<%
// create a global variable
var e;
function test(a,b)
{
try{}
catch(e){} // notice this variable is the same as the local and
global one one
}
Response.Write("works!")
%>
--END PAGE--
-- BEGIN PAGE: test_success.aspx--
<%@Page Language="JScript"%>
<%
// create a global variable
var e;
function test(a,b)
{
// create a local variable
var e; // this works
try{
//var e; this works too
}
catch(e)
{
//var e; this works as well
} // notice this variable is the same as the local and global one
one
//var e; this doesn't work
}
Response.Write("works!")
%>