kevingadd/JSIL — Issue #56: Function call wose result is assigned to unused variable in try block is not generatd
Author: matra774
Created: 2012-01-04 09:18:10+00:00
State: open

If you assigned a result of function call to a local variable incide try block and this local variable is not used, then function call is not generated.

Example:

public object SomeFunctionWithSideEffect()
{
return null;
}

public void TestmethodCallNotGenerated()
{

try
{
var tmp =
SomeFunctionWithSideEffect();
}
catch (Exception ex)
{
SomeFunctionWithSideEffect(); // if you remove this, the result is the same
}

}

Generated code:

$.prototype.SomeFunctionWithSideEffect = function () {
return null;
};
$.prototype.TestmethodCallNotGenerated = function () {
try {
} catch ($exception) {
this.SomeFunctionWithSideEffect();
}
};

If you remove assignment to tmp variable or use the tmp variable alter, then correct code is generated.