Program: 132814
Project: 132814
Buggy source:
/** 
 * Processes part of an assignTarget path: the prefix of struct lookups. E.g. if we're trying to assign to x.field.field.field[0], then this function handles the 3x field lookups, making sure that a handle to x.field.field.field is put into a temp variable, say called t0 This will then return a new assignment target for t0[0] for further processing
 * @param context
 * @param lval
 * @return
 * @throws UserException
 * @throws UndefinedTypeException
 * @throws TypeMismatchException
 */
private LValue reduceStructLVal(Context context,LValue lval) throws UserException, UndefinedTypeException, TypeMismatchException {
  Var rootVar=context.lookupVarUser(lval.varName);
  ArrayList<String> fieldPath=new ArrayList<String>();
  int structPathIndex=0;
  while (structPathIndex < lval.indices.size() && lval.indices.get(structPathIndex).getType() == ExMParser.STRUCT_PATH) {
    SwiftAST pathTree=lval.indices.get(structPathIndex);
    String fieldName=pathTree.child(0).getText();
    fieldPath.add(fieldName);
    structPathIndex++;
  }
  final int structPathLen=structPathIndex;
  Var fieldAlias=varCreator.createStructFieldAlias(context,rootVar,lval.getType(context,structPathLen - 1),fieldPath);
  backend.structCreateAlias(VarRepr.backendVar(fieldAlias),VarRepr.backendVar(rootVar),fieldPath);
  List<SwiftAST> indicesLeft=lval.indices.subList(structPathLen,lval.indices.size());
  LValue newTarget=new LValue(lval,lval.tree,fieldAlias,indicesLeft);
  LogHelper.trace(context,"String_Node_Str" + lval.toString() + "String_Node_Str"+ lval.getType(context).toString()+ "String_Node_Str"+ newTarget.toString()+ "String_Node_Str"+ newTarget.getType(context).toString()+ "String_Node_Str"+ structPathLen+ "String_Node_Str");
  return newTarget;
}

Fixed version (ground truth):
/** 
 * Processes part of an assignTarget path: the prefix of struct lookups. E.g. if we're trying to assign to x.field.field.field[0], then this function handles the 3x field lookups, making sure that a handle to x.field.field.field is put into a temp variable, say called t0 This will then return a new assignment target for t0[0] for further processing
 * @param context
 * @param lval
 * @return
 * @throws UserException
 * @throws UndefinedTypeException
 * @throws TypeMismatchException
 */
private LValue reduceStructLVal(Context context,LValue lval) throws UserException, UndefinedTypeException, TypeMismatchException {
  Var rootVar=context.lookupVarUser(lval.varName);
  ArrayList<String> fieldPath=new ArrayList<String>();
  int structPathIndex=0;
  while (structPathIndex < lval.indices.size() && lval.indices.get(structPathIndex).getType() == ExMParser.STRUCT_PATH) {
    SwiftAST pathTree=lval.indices.get(structPathIndex);
    String fieldName=pathTree.child(0).getText();
    fieldPath.add(fieldName);
    structPathIndex++;
  }
  final int structPathLen=structPathIndex;
  Var fieldAlias=varCreator.createStructFieldAlias(context,rootVar,lval.getType(context,structPathLen),fieldPath);
  backend.structCreateAlias(VarRepr.backendVar(fieldAlias),VarRepr.backendVar(rootVar),fieldPath);
  List<SwiftAST> indicesLeft=lval.indices.subList(structPathLen,lval.indices.size());
  LValue newTarget=new LValue(lval,lval.tree,fieldAlias,indicesLeft);
  LogHelper.trace(context,"String_Node_Str" + lval.toString() + "String_Node_Str"+ lval.getType(context).toString()+ "String_Node_Str"+ newTarget.toString()+ "String_Node_Str"+ newTarget.getType(context).toString()+ "String_Node_Str"+ structPathLen+ "String_Node_Str");
  return newTarget;
}