Program: 15563
Project: 15563
Buggy source:
void accept(Environment env) throws TemplateException {
  final Environment.Namespace namespace;
  if (namespaceExp == null) {
switch (scope) {
case LOCAL:
      namespace=null;
    break;
case GLOBAL:
  namespace=env.getGlobalNamespace();
break;
case NAMESPACE:
namespace=env.getCurrentNamespace();
break;
default :
throw new BugException("String_Node_Str" + scope);
}
}
 else {
TemplateModel namespaceTM=namespaceExp.eval(env);
try {
namespace=(Environment.Namespace)namespaceTM;
}
 catch (ClassCastException e) {
throw new NonNamespaceException(namespaceExp,namespaceTM,env);
}
if (namespace == null) {
throw InvalidReferenceException.getInstance(namespaceExp,env);
}
}
TemplateModel value;
if (operatorType == OPERATOR_TYPE_EQUALS) {
value=valueExp.eval(env);
if (value == null) {
if (env.isClassicCompatible()) {
value=TemplateScalarModel.EMPTY_STRING;
}
 else {
throw InvalidReferenceException.getInstance(valueExp,env);
}
}
}
 else {
TemplateModel lhoValue;
if (namespace == null) {
lhoValue=env.getLocalVariable(variableName);
}
 else {
lhoValue=namespace.get(variableName);
}
if (lhoValue == null) {
if (env.isClassicCompatible()) {
lhoValue=TemplateScalarModel.EMPTY_STRING;
}
 else {
throw InvalidReferenceException.getInstance(variableName,getOperatorTypeAsString(),env);
}
}
if (operatorType == OPERATOR_TYPE_PLUS_EQUALS) {
value=valueExp.eval(env);
if (value == null) {
if (env.isClassicCompatible()) {
value=TemplateScalarModel.EMPTY_STRING;
}
 else {
throw InvalidReferenceException.getInstance(valueExp,env);
}
}
value=AddConcatExpression._eval(env,namespaceExp,null,lhoValue,valueExp,value);
}
 else {
Number lhoNumber;
if (lhoValue instanceof TemplateNumberModel) {
lhoNumber=EvalUtil.modelToNumber((TemplateNumberModel)lhoValue,null);
}
 else {
throw new NonNumericalException(variableName,lhoValue,null,env);
}
if (operatorType == OPERATOR_TYPE_PLUS_PLUS) {
value=AddConcatExpression._evalOnNumbers(env,parent,lhoNumber,ONE);
}
 else if (operatorType == OPERATOR_TYPE_MINUS_MINUS) {
value=ArithmeticExpression._eval(env,parent,lhoNumber,ArithmeticExpression.TYPE_SUBSTRACTION,ONE);
}
 else {
Number rhoNumber=valueExp.evalToNumber(env);
value=ArithmeticExpression._eval(env,this,lhoNumber,operatorType,rhoNumber);
}
}
}
if (namespace == null) {
env.setLocalVariable(variableName,value);
}
 else {
namespace.put(variableName,value);
}
}

Fixed version (ground truth):
void accept(Environment env) throws TemplateException {
  final Environment.Namespace namespace;
  if (namespaceExp == null) {
switch (scope) {
case LOCAL:
      namespace=null;
    break;
case GLOBAL:
  namespace=env.getGlobalNamespace();
break;
case NAMESPACE:
namespace=env.getCurrentNamespace();
break;
default :
throw new BugException("String_Node_Str" + scope);
}
}
 else {
TemplateModel namespaceTM=namespaceExp.eval(env);
try {
namespace=(Environment.Namespace)namespaceTM;
}
 catch (ClassCastException e) {
throw new NonNamespaceException(namespaceExp,namespaceTM,env);
}
if (namespace == null) {
throw InvalidReferenceException.getInstance(namespaceExp,env);
}
}
TemplateModel value;
if (operatorType == OPERATOR_TYPE_EQUALS) {
value=valueExp.eval(env);
if (value == null) {
if (env.isClassicCompatible()) {
value=TemplateScalarModel.EMPTY_STRING;
}
 else {
throw InvalidReferenceException.getInstance(valueExp,env);
}
}
}
 else {
TemplateModel lhoValue;
if (namespace == null) {
lhoValue=env.getLocalVariable(variableName);
}
 else {
lhoValue=namespace.get(variableName);
}
if (operatorType == OPERATOR_TYPE_PLUS_EQUALS) {
if (lhoValue == null) {
if (env.isClassicCompatible()) {
lhoValue=TemplateScalarModel.EMPTY_STRING;
}
 else {
throw InvalidReferenceException.getInstance(variableName,getOperatorTypeAsString(),env);
}
}
value=valueExp.eval(env);
if (value == null) {
if (env.isClassicCompatible()) {
value=TemplateScalarModel.EMPTY_STRING;
}
 else {
throw InvalidReferenceException.getInstance(valueExp,env);
}
}
value=AddConcatExpression._eval(env,namespaceExp,null,lhoValue,valueExp,value);
}
 else {
Number lhoNumber;
if (lhoValue instanceof TemplateNumberModel) {
lhoNumber=EvalUtil.modelToNumber((TemplateNumberModel)lhoValue,null);
}
 else if (lhoValue == null) {
throw InvalidReferenceException.getInstance(variableName,getOperatorTypeAsString(),env);
}
 else {
throw new NonNumericalException(variableName,lhoValue,null,env);
}
if (operatorType == OPERATOR_TYPE_PLUS_PLUS) {
value=AddConcatExpression._evalOnNumbers(env,parent,lhoNumber,ONE);
}
 else if (operatorType == OPERATOR_TYPE_MINUS_MINUS) {
value=ArithmeticExpression._eval(env,parent,lhoNumber,ArithmeticExpression.TYPE_SUBSTRACTION,ONE);
}
 else {
Number rhoNumber=valueExp.evalToNumber(env);
value=ArithmeticExpression._eval(env,this,lhoNumber,operatorType,rhoNumber);
}
}
}
if (namespace == null) {
env.setLocalVariable(variableName,value);
}
 else {
namespace.put(variableName,value);
}
}