Program: 15772
Project: 15772
Buggy source:
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
  TemplateModel leftModel=left.getAsTemplateModel(env);
  TemplateModel rightModel=right.getAsTemplateModel(env);
  if (leftModel instanceof TemplateNumberModel && rightModel instanceof TemplateNumberModel) {
    Number first=EvaluationUtil.getNumber((TemplateNumberModel)leftModel,left,env);
    Number second=EvaluationUtil.getNumber((TemplateNumberModel)rightModel,right,env);
    ArithmeticEngine ae=env != null ? env.getArithmeticEngine() : getTemplate().getArithmeticEngine();
    return new SimpleNumber(ae.add(first,second));
  }
 else   if (leftModel instanceof TemplateSequenceModel && rightModel instanceof TemplateSequenceModel) {
    return new ConcatenatedSequence((TemplateSequenceModel)leftModel,(TemplateSequenceModel)rightModel);
  }
 else {
    try {
      String s1=getStringValue(leftModel,left,env);
      if (s1 == null)       s1="String_Node_Str";
      String s2=getStringValue(rightModel,right,env);
      if (s2 == null)       s2="String_Node_Str";
      return new SimpleScalar(s1.concat(s2));
    }
 catch (    NonStringException e) {
      if (leftModel instanceof TemplateHashModel && rightModel instanceof TemplateHashModel) {
        if (leftModel instanceof TemplateHashModelEx && rightModel instanceof TemplateHashModelEx) {
          TemplateHashModelEx leftModelEx=(TemplateHashModelEx)leftModel;
          TemplateHashModelEx rightModelEx=(TemplateHashModelEx)rightModel;
          if (leftModelEx.size() == 0) {
            return rightModelEx;
          }
 else           if (rightModelEx.size() == 0) {
            return leftModelEx;
          }
 else {
            return new ConcatenatedHashEx(leftModelEx,rightModelEx);
          }
        }
 else {
          return new ConcatenatedHash((TemplateHashModel)leftModel,(TemplateHashModel)rightModel);
        }
      }
 else {
        throw e;
      }
    }
  }
}

Fixed version (ground truth):
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException {
  TemplateModel leftModel=left.getAsTemplateModel(env);
  TemplateModel rightModel=right.getAsTemplateModel(env);
  if (leftModel instanceof TemplateNumberModel && rightModel instanceof TemplateNumberModel) {
    Number first=EvaluationUtil.getNumber((TemplateNumberModel)leftModel,left,env);
    Number second=EvaluationUtil.getNumber((TemplateNumberModel)rightModel,right,env);
    ArithmeticEngine ae=env != null ? env.getArithmeticEngine() : getTemplate().getArithmeticEngine();
    return new SimpleNumber(ae.add(first,second));
  }
 else   if (leftModel instanceof TemplateSequenceModel && rightModel instanceof TemplateSequenceModel) {
    return new ConcatenatedSequence((TemplateSequenceModel)leftModel,(TemplateSequenceModel)rightModel);
  }
 else {
    try {
      String s1=Expression.getCoercedStringValue(leftModel,left,env);
      if (s1 == null)       s1="String_Node_Str";
      String s2=Expression.getCoercedStringValue(rightModel,right,env);
      if (s2 == null)       s2="String_Node_Str";
      return new SimpleScalar(s1.concat(s2));
    }
 catch (    NonStringException e) {
      if (leftModel instanceof TemplateHashModel && rightModel instanceof TemplateHashModel) {
        if (leftModel instanceof TemplateHashModelEx && rightModel instanceof TemplateHashModelEx) {
          TemplateHashModelEx leftModelEx=(TemplateHashModelEx)leftModel;
          TemplateHashModelEx rightModelEx=(TemplateHashModelEx)rightModel;
          if (leftModelEx.size() == 0) {
            return rightModelEx;
          }
 else           if (rightModelEx.size() == 0) {
            return leftModelEx;
          }
 else {
            return new ConcatenatedHashEx(leftModelEx,rightModelEx);
          }
        }
 else {
          return new ConcatenatedHash((TemplateHashModel)leftModel,(TemplateHashModel)rightModel);
        }
      }
 else {
        throw e;
      }
    }
  }
}