nus-yam/ex-repair huggingface dataset:
Program: 132649
Project: 132649
Buggy source:
public static void checkCopy(Context context,Type srctype,Type dsttype) throws TypeMismatchException {
  if (!(srctype.assignableTo(dsttype) && srctype.getImplType().equals(dsttype.getImplType()))) {
    new Exception().printStackTrace();
    throw new TypeMismatchException(context,"String_Node_Str" + srctype.toString() + "String_Node_Str"+ dsttype.toString());
  }
}

Fixed version (ground truth):
public static void checkCopy(Context context,Type srctype,Type dsttype) throws TypeMismatchException {
  if (!(srctype.assignableTo(dsttype) && srctype.getImplType().equals(dsttype.getImplType()))) {
    throw new TypeMismatchException(context,"String_Node_Str" + srctype.toString() + "String_Node_Str"+ dsttype.toString());
  }
}
Program: 132650
Project: 132650
Buggy source:
private static Type structLoad(Context context,SwiftAST tree) throws UserException, TypeMismatchException {
  Type structType=findExprType(context,tree.child(0));
  String fieldName=tree.child(1).getText();
  Type fieldType;
  fieldType=findStructFieldType(context,fieldName,structType);
  if (fieldType == null) {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ ((StructType)structType).getStructTypeName());
  }
  if (Types.isStruct(structType)) {
    return fieldType;
  }
 else {
    assert(Types.isStructRef(structType));
    return VarRepr.containerElemRepr(fieldType,false);
  }
}

Fixed version (ground truth):
private static Type structLoad(Context context,SwiftAST tree) throws UserException, TypeMismatchException {
  Type structType=findExprType(context,tree.child(0));
  String fieldName=tree.child(1).getText();
  Type fieldType;
  fieldType=findStructFieldType(context,fieldName,structType);
  if (fieldType == null) {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ ((StructType)structType).getStructTypeName());
  }
  return structLoadResultType(structType,fieldType);
}
Program: 132651
Project: 132651
Buggy source:
/** 
 * @param context
 * @param branchVUs The variable usage info for all branches
 * @param writtenVars All vars that might be written are added here
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void summariseBranchVariableUsage(Context context,List<VariableUsageInfo> branchVUs,List<Var> writtenVars) throws UndefinedTypeException, UserException {
  for (  Var v : context.getVisibleVariables()) {
    if (Types.isArray(v.type())) {
      for (      VariableUsageInfo bvu : branchVUs) {
        VInfo vi=bvu.lookupVariableInfo(v.name());
        if (vi != null && vi.isAssigned() != Ternary.FALSE) {
          writtenVars.add(v);
          break;
        }
      }
    }
 else     if (Types.isStruct(v.type())) {
      ArrayList<Pair<Var,VInfo>> arrs=new ArrayList<Pair<Var,VInfo>>();
      HashSet<Var> alreadyFound=new HashSet<Var>();
      for (      VariableUsageInfo bvu : branchVUs) {
        arrs.clear();
        exprWalker.findArraysInStruct(context,v,bvu.lookupVariableInfo(v.name()),arrs);
        for (        Pair<Var,VInfo> p : arrs) {
          if (p.val2.isAssigned() != Ternary.FALSE) {
            alreadyFound.add(p.val1);
          }
        }
      }
      writtenVars.addAll(alreadyFound);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param context
 * @param branchVUs The variable usage info for all branches
 * @param writtenVars All vars that might be written are added here
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void summariseBranchVariableUsage(Context context,List<VariableUsageInfo> branchVUs,List<Var> writtenVars) throws UndefinedTypeException, UserException {
  for (  Var v : context.getVisibleVariables()) {
    if (Types.isArray(v.type())) {
      for (      VariableUsageInfo bvu : branchVUs) {
        VInfo vi=bvu.lookupVariableInfo(v.name());
        if (vi != null && vi.isAssigned() != Ternary.FALSE) {
          writtenVars.add(v);
          break;
        }
      }
    }
 else     if (Types.isStruct(v.type())) {
      ArrayList<Pair<Var,VInfo>> arrs=new ArrayList<Pair<Var,VInfo>>();
      HashSet<Var> alreadyFound=new HashSet<Var>();
      for (      VariableUsageInfo bvu : branchVUs) {
        arrs.clear();
        VInfo vi=bvu.lookupVariableInfo(v.name());
        if (vi != null) {
          exprWalker.findArraysInStruct(context,v,vi,arrs);
          for (          Pair<Var,VInfo> p : arrs) {
            if (p.val2.isAssigned() != Ternary.FALSE) {
              alreadyFound.add(p.val1);
            }
          }
        }
      }
      writtenVars.addAll(alreadyFound);
    }
  }
}
Program: 132652
Project: 132652
Buggy source:
private void findArraysInStructToClose(Context context,Var struct,VInfo structVInfo,StackLite<String> fieldPath,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  assert(structVInfo != null);
  StructType vtype=(StructType)struct.type();
  for (  StructField f : vtype.getFields()) {
    fieldPath.push(f.getName());
    if (Types.isArray(f.getType())) {
      Var fieldVar=structLookup(context,struct,fieldPath,false);
      VInfo fieldInfo=structVInfo != null ? structVInfo.getFieldVInfo(f.getName()) : null;
      arrays.add(Pair.create(fieldVar,fieldInfo));
    }
 else     if (Types.isStruct(f.getType())) {
      VInfo nestedVInfo=structVInfo.getFieldVInfo(f.getName());
      findArraysInStructToClose(context,struct,nestedVInfo,fieldPath,arrays);
    }
    fieldPath.pop();
  }
}

Fixed version (ground truth):
/** 
 * @param context
 * @param rootStruct root struct
 * @param currStructType current structure type (of root of sub-structure)
 * @param currStructVInfo
 * @param fieldPath
 * @param arrays
 * @throws UndefinedTypeException
 * @throws UserException
 */
private void findArraysInStructToClose(Context context,Var rootStruct,StructType currStructType,VInfo currStructVInfo,StackLite<String> fieldPath,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  assert(currStructVInfo != null);
  for (  StructField f : currStructType.getFields()) {
    fieldPath.push(f.getName());
    if (Types.isArray(f.getType())) {
      Var fieldVar=structLookup(context,rootStruct,fieldPath,false);
      VInfo fieldInfo=currStructVInfo != null ? currStructVInfo.getFieldVInfo(f.getName()) : null;
      arrays.add(Pair.create(fieldVar,fieldInfo));
    }
 else     if (Types.isStruct(f.getType())) {
      VInfo nestedVInfo=currStructVInfo.getFieldVInfo(f.getName());
      findArraysInStructToClose(context,rootStruct,(StructType)f.getType(),nestedVInfo,fieldPath,arrays);
    }
    fieldPath.pop();
  }
}
Program: 132653
Project: 132653
Buggy source:
void findArraysInStruct(Context context,Var root,VInfo structVInfo,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  findArraysInStructToClose(context,root,structVInfo,new StackLite<String>(),arrays);
}

Fixed version (ground truth):
void findArraysInStruct(Context context,Var root,VInfo structVInfo,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  assert(Types.isStruct(root));
  findArraysInStructToClose(context,root,(StructType)root.type(),structVInfo,new StackLite<String>(),arrays);
}
Program: 132654
Project: 132654
Buggy source:
/** 
 * Find the type of a particular field
 * @param context
 * @param fieldName
 * @param type a struct or a reference to a struct
 * @return
 * @throws TypeMismatchException if the type isn't a struct or struct ref,or the field doesn't exist in the type
 */
public static Type findStructFieldType(Context context,String fieldName,Type type) throws TypeMismatchException {
  StructType structType;
  if (Types.isStruct(type)) {
    structType=((StructType)type);
  }
 else   if (Types.isStructRef(type)) {
    structType=((StructType)(type.memberType()));
  }
 else {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ type.toString());
  }
  Type fieldType=structType.getFieldTypeByName(fieldName);
  if (fieldType == null) {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ structType.typeName());
  }
  return fieldType;
}

Fixed version (ground truth):
/** 
 * Find the type of a particular field
 * @param context
 * @param fieldName
 * @param type a struct or a reference to a struct
 * @return
 * @throws TypeMismatchException if the type isn't a struct or struct ref,or the field doesn't exist in the type
 */
public static Type findStructFieldType(Context context,String fieldName,Type type) throws TypeMismatchException {
  StructType structType;
  if (Types.isStruct(type)) {
    structType=((StructType)type);
  }
 else   if (Types.isStructRef(type)) {
    structType=((StructType)(type.memberType()));
  }
 else {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ type.toString());
  }
  Type fieldType=structType.getFieldTypeByName(fieldName);
  if (fieldType == null) {
    new Exception().printStackTrace();
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ structType.typeName()+ "String_Node_Str"+ "String_Node_Str"+ structType.getFields());
  }
  return fieldType;
}
Program: 132655
Project: 132655
Buggy source:
private List<Arg> canonicalizeAssignValue(GlobalConstants consts,ArgCV val){
  if (val.isArrayMemberVal() || val.isArrayMember()) {
    Arg arr=byAlias.findCanonical(val.getInput(0));
    Arg ix=byValue.findCanonical(val.getInput(1));
    return Arrays.asList(arr,ix);
  }
 else   if (val.isStructFieldVal() || val.isStructFieldAlias() || val.isStructFieldCopy()|| val.isStructFieldValRef()) {
    Arg struct=byAlias.findCanonical(val.getInput(0));
    Arg fieldName=byValue.findCanonical(val.getInput(1));
    return Arrays.asList(struct,fieldName);
  }
 else   if (val.isFilenameValCV() || val.isFilenameAliasCV() || val.isLocalFilenameCV()) {
    return Arrays.asList(Arg.createStringLit("String_Node_Str"),byAlias.findCanonical(val.getInput(0)));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + val + "String_Node_Str");
  }
}

Fixed version (ground truth):
private List<Arg> canonicalizeAssignValue(GlobalConstants consts,ArgCV val){
  if (val.isArrayMemberVal() || val.isArrayMember()) {
    Arg arr=byAlias.findCanonical(val.getInput(0));
    Arg ix=byValue.findCanonical(val.getInput(1));
    return Arrays.asList(arr,ix);
  }
 else   if (val.isStructFieldVal() || val.isStructFieldAlias() || val.isStructFieldCopy()|| val.isStructFieldValRef()) {
    List<Arg> inputs=val.getInputs();
    List<Arg> result=new ArrayList<Arg>(inputs.size());
    assert(inputs.size() >= 2);
    Arg struct=inputs.get(0);
    result.add(byAlias.findCanonical(struct));
    for (int i=1; i < inputs.size(); i++) {
      Arg field=inputs.get(i);
      result.add(byValue.findCanonical(field));
    }
    return result;
  }
 else   if (val.isFilenameValCV() || val.isFilenameAliasCV() || val.isLocalFilenameCV()) {
    return Arrays.asList(Arg.createStringLit("String_Node_Str"),byAlias.findCanonical(val.getInput(0)));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + val + "String_Node_Str");
  }
}
Program: 132656
Project: 132656
Buggy source:
/** 
 * Called once all usage info is collected
 * @return violations if this is a struct and it is incompletely specified
 */
public List<Violation> isIncompletelyDefinedStruct(Context context){
  if (Types.isStruct(this.type)) {
    ArrayList<Violation> result=new ArrayList<Violation>();
    Ternary assigned=isAssigned();
    if (assigned == Ternary.TRUE) {
      return result;
    }
 else     if (assigned == Ternary.MAYBE && isRead() != Ternary.FALSE) {
      result.add(new Violation(ViolationType.WARNING,this.getName() + "String_Node_Str",context));
    }
    for (    VInfo vi : structFields.values()) {
      if (vi.isAssigned() != Ternary.TRUE) {
        if (vi.isAssigned() == Ternary.FALSE && vi.isRead() == Ternary.TRUE) {
          result.add(new Violation(ViolationType.ERROR,"String_Node_Str" + vi.getName() + "String_Node_Str"+ "String_Node_Str",context));
        }
 else         if (assigned != Ternary.FALSE) {
          result.add(new Violation(ViolationType.WARNING,vi.getName() + "String_Node_Str" + "String_Node_Str",context));
        }
      }
      List<Violation> more=vi.isIncompletelyDefinedStruct(context);
      if (more != null)       result.addAll(more);
    }
    return result;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Called once all usage info is collected
 * @return violations if this is a struct and it is incompletely specified
 */
public List<Violation> isIncompletelyDefinedStruct(Context context){
  if (Types.isStruct(this.type)) {
    ArrayList<Violation> result=new ArrayList<Violation>();
    Ternary assigned=isAssigned();
    if (assigned == Ternary.TRUE) {
      return result;
    }
 else     if (assigned == Ternary.MAYBE && isRead() != Ternary.FALSE) {
      result.add(new Violation(ViolationType.WARNING,this.getName() + "String_Node_Str",context));
    }
    for (    VInfo vi : structFields.values()) {
      Ternary somehowAssigned=Ternary.or(vi.isAssigned(),vi.isPartAssigned());
      if (somehowAssigned != Ternary.TRUE) {
        if (somehowAssigned == Ternary.FALSE && vi.isRead() == Ternary.TRUE) {
          result.add(new Violation(ViolationType.ERROR,"String_Node_Str" + vi.getName() + "String_Node_Str"+ "String_Node_Str",context));
        }
 else         if (somehowAssigned != Ternary.FALSE) {
          result.add(new Violation(ViolationType.WARNING,vi.getName() + "String_Node_Str" + "String_Node_Str",context));
        }
      }
      List<Violation> more=vi.isIncompletelyDefinedStruct(context);
      if (more != null)       result.addAll(more);
    }
    return result;
  }
 else {
    return null;
  }
}
Program: 132657
Project: 132657
Buggy source:
private List<Violation> structAssign(Context context,List<String> fieldPath,int arrayDepth,AssignOp op){
  VInfo fieldVInfo;
  List<Violation> errs=new ArrayList<Violation>();
  if (structFields != null) {
    if (this.assigned == Ternary.TRUE) {
      return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + fieldPath + "String_Node_Str"+ this.name+ "String_Node_Str",context));
    }
 else     if (this.assigned == Ternary.MAYBE) {
      errs.add(new Violation(ViolationType.WARNING,"String_Node_Str" + fieldPath + "String_Node_Str"+ this.name+ "String_Node_Str",context));
    }
    String field=fieldPath.get(0);
    if (structFields.containsKey(field)) {
      fieldVInfo=structFields.get(field);
    }
 else {
      return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + field + "String_Node_Str"+ this.name+ "String_Node_Str"+ ((StructType)type).getStructTypeName(),context));
    }
  }
 else {
    return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + this.name + "String_Node_Str",context));
  }
  fieldPath.remove(0);
  errs.addAll(fieldVInfo.assign(context,fieldPath,arrayDepth,op));
  mergeStructFieldWriteInfo(context);
  return errs;
}

Fixed version (ground truth):
private List<Violation> structAssign(Context context,List<String> fieldPath,int arrayDepth,AssignOp op){
  VInfo fieldVInfo;
  List<Violation> errs=new ArrayList<Violation>();
  if (structFields != null) {
    if (this.assigned == Ternary.TRUE) {
      return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + fieldPath + "String_Node_Str"+ this.name+ "String_Node_Str",context));
    }
 else     if (this.assigned == Ternary.MAYBE) {
      errs.add(new Violation(ViolationType.WARNING,"String_Node_Str" + fieldPath + "String_Node_Str"+ this.name+ "String_Node_Str",context));
    }
    String field=fieldPath.get(0);
    if (structFields.containsKey(field)) {
      fieldVInfo=structFields.get(field);
    }
 else {
      return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + field + "String_Node_Str"+ this.name+ "String_Node_Str"+ ((StructType)type).getStructTypeName(),context));
    }
  }
 else {
    return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + this.name + "String_Node_Str",context));
  }
  fieldPath.remove(0);
  errs.addAll(fieldVInfo.assign(context,fieldPath,arrayDepth,op));
  return errs;
}
Program: 132658
Project: 132658
Buggy source:
private Var derefOrCopyResult(Context context,Var lookupResult,Var outVar) throws UndefinedTypeException, UserException {
  try {
    if (outVar == null) {
      return lookupResult;
    }
 else     if (Types.isAssignableRefTo(lookupResult.type(),outVar.type())) {
      dereference(context,outVar,lookupResult);
      return outVar;
    }
 else {
      copyByValue(context,outVar,lookupResult);
      return outVar;
    }
  }
 catch (  RuntimeException e) {
    Logging.getSTCLogger().debug("String_Node_Str" + lookupResult + "String_Node_Str"+ outVar);
    throw e;
  }
}

Fixed version (ground truth):
private Var derefOrCopyResult(Context context,Var lookupResult,Var outVar) throws UndefinedTypeException, UserException {
  try {
    if (outVar == null) {
      return lookupResult;
    }
 else     if (Types.isRefTo(lookupResult.type(),outVar.type())) {
      dereference(context,outVar,lookupResult);
      return outVar;
    }
 else {
      copyByValue(context,outVar,lookupResult);
      return outVar;
    }
  }
 catch (  RuntimeException e) {
    Logging.getSTCLogger().debug("String_Node_Str" + lookupResult + "String_Node_Str"+ outVar);
    throw e;
  }
}
Program: 132659
Project: 132659
Buggy source:
public static void checkCopy(Context context,Type srctype,Type dsttype) throws TypeMismatchException {
  if (!(srctype.assignableTo(dsttype) && srctype.getImplType().equals(dsttype.getImplType()))) {
    new Exception().printStackTrace();
    throw new TypeMismatchException(context,"String_Node_Str" + srctype.toString() + "String_Node_Str"+ dsttype.toString());
  }
}

Fixed version (ground truth):
public static void checkCopy(Context context,Type srctype,Type dsttype) throws TypeMismatchException {
  if (!(srctype.assignableTo(dsttype) && srctype.getImplType().equals(dsttype.getImplType()))) {
    throw new TypeMismatchException(context,"String_Node_Str" + srctype.toString() + "String_Node_Str"+ dsttype.toString());
  }
}
Program: 132660
Project: 132660
Buggy source:
private static Type structLoad(Context context,SwiftAST tree) throws UserException, TypeMismatchException {
  Type structType=findExprType(context,tree.child(0));
  String fieldName=tree.child(1).getText();
  Type fieldType;
  fieldType=findStructFieldType(context,fieldName,structType);
  if (fieldType == null) {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ ((StructType)structType).getStructTypeName());
  }
  if (Types.isStruct(structType)) {
    return fieldType;
  }
 else {
    assert(Types.isStructRef(structType));
    return VarRepr.containerElemRepr(fieldType,false);
  }
}

Fixed version (ground truth):
private static Type structLoad(Context context,SwiftAST tree) throws UserException, TypeMismatchException {
  Type structType=findExprType(context,tree.child(0));
  String fieldName=tree.child(1).getText();
  Type fieldType;
  fieldType=findStructFieldType(context,fieldName,structType);
  if (fieldType == null) {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ ((StructType)structType).getStructTypeName());
  }
  return structLoadResultType(structType,fieldType);
}
Program: 132661
Project: 132661
Buggy source:
private static Type unpackedStructType(Type type,StructType structType){
  List<StructField> packedFields=structType.getFields();
  List<StructField> unpackedFields=new ArrayList<StructField>(packedFields.size());
  boolean differences=false;
  for (  StructField packedField : packedFields) {
    Type packedFieldType=packedField.getType();
    Type unpackedFieldType=unpackedType(packedFieldType);
    if (unpackedFieldType.equals(packedFieldType)) {
      unpackedFields.add(packedField);
    }
 else {
      StructField unpackedField=new StructField(unpackedFieldType,packedField.getName());
      unpackedFields.add(unpackedField);
      differences=true;
    }
  }
  if (differences) {
    return new StructType(true,"String_Node_Str" + type.typeName(),unpackedFields);
  }
 else {
    return structType;
  }
}

Fixed version (ground truth):
private static Type unpackedStructType(Type type,StructType structType){
  List<StructField> packedFields=structType.getFields();
  List<StructField> unpackedFields=new ArrayList<StructField>(packedFields.size());
  boolean differences=false;
  for (  StructField packedField : packedFields) {
    Type packedFieldType=packedField.getType();
    Type unpackedFieldType=unpackedType(packedFieldType);
    if (unpackedFieldType.equals(packedFieldType)) {
      unpackedFields.add(packedField);
    }
 else {
      StructField unpackedField=new StructField(unpackedFieldType,packedField.getName());
      unpackedFields.add(unpackedField);
      differences=true;
    }
  }
  if (differences) {
    return new StructType(true,"String_Node_Str" + type.typeName(),unpackedFields);
  }
 else {
    return StructType.localStruct(structType);
  }
}
Program: 132662
Project: 132662
Buggy source:
/** 
 * The type that would result from a retrieve operation
 * @param t
 * @return
 */
public static Type retrievedType(Typed t,boolean recursive){
  if (isScalarFuture(t) || isScalarUpdateable(t)) {
    return new ScalarValueType(t.type().primType());
  }
 else   if (isFile(t)) {
    return new FileValueType(t.type().fileKind());
  }
 else   if (isRef(t)) {
    return t.type().baseType().memberType();
  }
 else   if (recursive && (isContainer(t) || isContainerLocal(t))) {
    return unpackedType(t);
  }
 else   if (isArray(t)) {
    assert(!recursive);
    ArrayType at=(ArrayType)t.type().getImplType();
    Type retrievedMemberType=retrievedType(at.memberType(),false);
    return ArrayType.localArray(at.keyType(),retrievedMemberType);
  }
 else   if (isBag(t)) {
    assert(!recursive);
    BagType bt=(BagType)t.type().getImplType();
    Type retrievedMemberType=retrievedType(bt.memberType(),false);
    return BagType.localBag(retrievedMemberType);
  }
 else   if (isStruct(t)) {
    StructType st=(StructType)t.type().getImplType();
    if (recursive) {
      for (      StructField f : st.getFields()) {
        if (Types.isRef(f.getType())) {
          throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + st);
        }
      }
    }
    return StructType.localStruct(st);
  }
 else {
    throw new STCRuntimeError(t.type() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * The type that would result from a retrieve operation
 * @param t
 * @return
 */
public static Type retrievedType(Typed t,boolean recursive){
  if (isScalarFuture(t) || isScalarUpdateable(t)) {
    return new ScalarValueType(t.type().primType());
  }
 else   if (isFile(t)) {
    return new FileValueType(t.type().fileKind());
  }
 else   if (isRef(t)) {
    return t.type().baseType().memberType();
  }
 else   if (recursive && (isContainer(t) || isContainerLocal(t))) {
    return unpackedType(t);
  }
 else   if (isArray(t)) {
    assert(!recursive);
    ArrayType at=(ArrayType)t.type().getImplType();
    Type retrievedMemberType=retrievedType(at.memberType(),false);
    return ArrayType.localArray(at.keyType(),retrievedMemberType);
  }
 else   if (isBag(t)) {
    assert(!recursive);
    BagType bt=(BagType)t.type().getImplType();
    Type retrievedMemberType=retrievedType(bt.memberType(),false);
    return BagType.localBag(retrievedMemberType);
  }
 else   if (isStruct(t)) {
    StructType st=(StructType)t.type().getImplType();
    if (recursive) {
      return unpackedType(st);
    }
 else {
      return StructType.localStruct(st);
    }
  }
 else {
    throw new STCRuntimeError(t.type() + "String_Node_Str");
  }
}
Program: 132664
Project: 132664
Buggy source:
private static Type unpackedStructType(Type type,StructType structType){
  List<StructField> packedFields=structType.getFields();
  List<StructField> unpackedFields=new ArrayList<StructField>(packedFields.size());
  boolean differences=false;
  for (  StructField packedField : packedFields) {
    Type packedFieldType=packedField.getType();
    Type unpackedFieldType=unpackedType(packedFieldType);
    if (unpackedFieldType.equals(packedFieldType)) {
      unpackedFields.add(packedField);
    }
 else {
      StructField unpackedField=new StructField(unpackedFieldType,packedField.getName());
      unpackedFields.add(unpackedField);
      differences=true;
    }
  }
  if (differences) {
    return new StructType(true,"String_Node_Str" + type.typeName(),unpackedFields);
  }
 else {
    return StructType.localStruct(structType);
  }
}

Fixed version (ground truth):
private static Type unpackedStructType(StructType structType){
  List<StructField> packedFields=structType.getFields();
  List<StructField> unpackedFields=new ArrayList<StructField>(packedFields.size());
  boolean differences=false;
  for (  StructField packedField : packedFields) {
    Type packedFieldType=packedField.getType();
    Type unpackedFieldType;
    if (Types.isRef(packedFieldType)) {
      unpackedFieldType=unpackedType(packedFieldType);
    }
 else     if (Types.isStruct(packedFieldType)) {
      unpackedFieldType=unpackedStructType((StructType)packedFieldType);
    }
 else {
      unpackedFieldType=packedFieldType;
    }
    if (unpackedFieldType.equals(packedFieldType)) {
      unpackedFields.add(packedField);
    }
 else {
      StructField unpackedField=new StructField(unpackedFieldType,packedField.getName());
      unpackedFields.add(unpackedField);
      System.err.println(unpackedField + "String_Node_Str" + packedField);
      differences=true;
    }
  }
  if (differences) {
    return new StructType(true,"String_Node_Str" + structType.typeName(),unpackedFields);
  }
 else {
    return StructType.localStruct(structType);
  }
}
Program: 132665
Project: 132665
Buggy source:
/** 
 * Work out type of variable if we recursively extract all values into local variables
 * @param t
 * @return
 */
public static Type unpackedType(Typed t){
  Type type=stripRefs(t.type());
  if (Types.isContainer(type) || Types.isContainerLocal(type)) {
    return unpackedContainerType(type);
  }
 else   if (Types.isStruct(type) || Types.isStructLocal(type)) {
    return unpackedStructType(type,(StructType)type);
  }
 else {
    while (Types.canRetrieve(type)) {
      type=retrievedType(type);
    }
    return type;
  }
}

Fixed version (ground truth):
/** 
 * Work out type of variable if we recursively extract all values into local variables
 * @param t
 * @return
 */
public static Type unpackedType(Typed t){
  Type type=stripRefs(t.type());
  if (Types.isContainer(type) || Types.isContainerLocal(type)) {
    return unpackedContainerType(type);
  }
 else   if (Types.isStruct(type) || Types.isStructLocal(type)) {
    return unpackedStructType((StructType)type);
  }
 else {
    while (Types.canRetrieve(type)) {
      type=retrievedType(type);
    }
    return type;
  }
}
Program: 132666
Project: 132666
Buggy source:
/** 
 * Retrieve a struct directly to a local struct, without following any references
 * @param dst
 * @param src non-recursively closed struct
 * @return
 */
public static Instruction retrieveStruct(Var dst,Var src){
  assert(Types.isStruct(src.type()));
  assert(Types.isStructLocal(dst));
  assert(StructType.localStruct((StructType)src.type().getImplType()).assignableTo(dst.type()));
  return new TurbineOp(Opcode.LOAD_STRUCT,dst,src.asArg());
}

Fixed version (ground truth):
/** 
 * Retrieve a struct directly to a local struct, without following any references
 * @param dst
 * @param src non-recursively closed struct
 * @return
 */
public static Instruction retrieveStruct(Var dst,Var src){
}
Program: 132667
Project: 132667
Buggy source:
private List<Violation> arrayAssign(Context context,int arrayDepth,AssignOp op){
  if (assigned != Ternary.FALSE) {
    if (arrayAssignDepth != arrayDepth) {
      return Arrays.asList(makeArrDepthViolation(context,arrayDepth));
    }
    this.assigned=Ternary.TRUE;
  }
 else {
    this.assigned=Ternary.TRUE;
    arrayAssignDepth=arrayDepth;
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
private List<Violation> arrayAssign(Context context,int arrayDepth,AssignOp op){
  this.assigned=Ternary.TRUE;
  return Collections.emptyList();
}
Program: 132668
Project: 132668
Buggy source:
/** 
 * make a copy, except it might be in a different scope All of the usage tracking is reset
 */
public VInfo makeEmptyCopy(boolean locallyDeclared){
  HashMap<String,VInfo> structFieldsNew=null;
  if (structFields != null) {
    structFieldsNew=new HashMap<String,VInfo>();
    for (    Entry<String,VInfo> e : structFields.entrySet()) {
      structFieldsNew.put(e.getKey(),e.getValue().makeEmptyCopy(locallyDeclared));
    }
  }
  return new VInfo(type,hasMapping,structFieldsNew,locallyDeclared,name,Ternary.FALSE,Ternary.FALSE,Ternary.FALSE,0,-1);
}

Fixed version (ground truth):
/** 
 * make a copy, except it might be in a different scope All of the usage tracking is reset
 */
public VInfo makeEmptyCopy(boolean locallyDeclared){
  HashMap<String,VInfo> structFieldsNew=null;
  if (structFields != null) {
    structFieldsNew=new HashMap<String,VInfo>();
    for (    Entry<String,VInfo> e : structFields.entrySet()) {
      structFieldsNew.put(e.getKey(),e.getValue().makeEmptyCopy(locallyDeclared));
    }
  }
  return new VInfo(type,hasMapping,structFieldsNew,locallyDeclared,name,Ternary.FALSE,Ternary.FALSE,Ternary.FALSE,-1);
}
Program: 132669
Project: 132669
Buggy source:
private VInfo(Type type,boolean mapped,boolean locallyDeclared,String name,Ternary assigned,Ternary read,Ternary appended,int arrayAssignDepth,int maxReadDepth){
  this.type=type;
  this.hasMapping=mapped;
  if (Types.isStruct(type)) {
    structFields=new HashMap<String,VInfo>();
    for (    StructField f : ((StructType)type.getImplType()).getFields()) {
      VInfo fieldVInfo=new VInfo(f.getType(),mapped,name + "String_Node_Str" + f.getName(),locallyDeclared);
      structFields.put(f.getName(),fieldVInfo);
    }
  }
 else {
    structFields=null;
  }
  this.declaredInCurrentScope=locallyDeclared;
  this.name=name;
  this.assigned=assigned;
  this.appended=appended;
  this.read=read;
  this.arrayAssignDepth=arrayAssignDepth;
  this.maxReadDepth=maxReadDepth;
}

Fixed version (ground truth):
private VInfo(Type type,boolean mapped,boolean locallyDeclared,String name,Ternary assigned,Ternary read,Ternary appended,int maxReadDepth){
  this.type=type;
  this.hasMapping=mapped;
  if (Types.isStruct(type)) {
    structFields=new HashMap<String,VInfo>();
    for (    StructField f : ((StructType)type.getImplType()).getFields()) {
      VInfo fieldVInfo=new VInfo(f.getType(),mapped,name + "String_Node_Str" + f.getName(),locallyDeclared);
      structFields.put(f.getName(),fieldVInfo);
    }
  }
 else {
    structFields=null;
  }
  this.declaredInCurrentScope=locallyDeclared;
  this.name=name;
  this.assigned=assigned;
  this.appended=appended;
  this.read=read;
  this.maxReadDepth=maxReadDepth;
}
Program: 132671
Project: 132671
Buggy source:
/** 
 * @param context
 * @param branchVUs The variable usage info for all branches
 * @param writtenVars All vars that might be written are added here
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void summariseBranchVariableUsage(Context context,List<VariableUsageInfo> branchVUs,List<Var> writtenVars) throws UndefinedTypeException, UserException {
  for (  Var v : context.getVisibleVariables()) {
    if (Types.isArray(v.type())) {
      for (      VariableUsageInfo bvu : branchVUs) {
        VInfo vi=bvu.lookupVariableInfo(v.name());
        if (vi != null && vi.isAssigned() != Ternary.FALSE) {
          writtenVars.add(v);
          break;
        }
      }
    }
 else     if (Types.isStruct(v.type())) {
      ArrayList<Pair<Var,VInfo>> arrs=new ArrayList<Pair<Var,VInfo>>();
      HashSet<Var> alreadyFound=new HashSet<Var>();
      for (      VariableUsageInfo bvu : branchVUs) {
        arrs.clear();
        exprWalker.findArraysInStruct(context,v,bvu.lookupVariableInfo(v.name()),arrs);
        for (        Pair<Var,VInfo> p : arrs) {
          if (p.val2.isAssigned() != Ternary.FALSE) {
            alreadyFound.add(p.val1);
          }
        }
      }
      writtenVars.addAll(alreadyFound);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param context
 * @param branchVUs The variable usage info for all branches
 * @param writtenVars All vars that might be written are added here
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void summariseBranchVariableUsage(Context context,List<VariableUsageInfo> branchVUs,List<Var> writtenVars) throws UndefinedTypeException, UserException {
  for (  Var v : context.getVisibleVariables()) {
    if (Types.isArray(v.type())) {
      for (      VariableUsageInfo bvu : branchVUs) {
        VInfo vi=bvu.lookupVariableInfo(v.name());
        if (vi != null && vi.isAssigned() != Ternary.FALSE) {
          writtenVars.add(v);
          break;
        }
      }
    }
 else     if (Types.isStruct(v.type())) {
      ArrayList<Pair<Var,VInfo>> arrs=new ArrayList<Pair<Var,VInfo>>();
      HashSet<Var> alreadyFound=new HashSet<Var>();
      for (      VariableUsageInfo bvu : branchVUs) {
        arrs.clear();
        VInfo vi=bvu.lookupVariableInfo(v.name());
        if (vi != null) {
          exprWalker.findArraysInStruct(context,v,vi,arrs);
          for (          Pair<Var,VInfo> p : arrs) {
            if (p.val2.isAssigned() != Ternary.FALSE) {
              alreadyFound.add(p.val1);
            }
          }
        }
      }
      writtenVars.addAll(alreadyFound);
    }
  }
}
Program: 132672
Project: 132672
Buggy source:
private void findArraysInStructToClose(Context context,Var struct,VInfo structVInfo,StackLite<String> fieldPath,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  assert(structVInfo != null);
  StructType vtype=(StructType)struct.type();
  for (  StructField f : vtype.getFields()) {
    fieldPath.push(f.getName());
    if (Types.isArray(f.getType())) {
      Var fieldVar=structLookup(context,struct,fieldPath,false);
      VInfo fieldInfo=structVInfo != null ? structVInfo.getFieldVInfo(f.getName()) : null;
      arrays.add(Pair.create(fieldVar,fieldInfo));
    }
 else     if (Types.isStruct(f.getType())) {
      VInfo nestedVInfo=structVInfo.getFieldVInfo(f.getName());
      findArraysInStructToClose(context,struct,nestedVInfo,fieldPath,arrays);
    }
    fieldPath.pop();
  }
}

Fixed version (ground truth):
/** 
 * @param context
 * @param rootStruct root struct
 * @param currStructType current structure type (of root of sub-structure)
 * @param currStructVInfo
 * @param fieldPath
 * @param arrays
 * @throws UndefinedTypeException
 * @throws UserException
 */
private void findArraysInStructToClose(Context context,Var rootStruct,StructType currStructType,VInfo currStructVInfo,StackLite<String> fieldPath,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  assert(currStructVInfo != null);
  for (  StructField f : currStructType.getFields()) {
    fieldPath.push(f.getName());
    if (Types.isArray(f.getType())) {
      Var fieldVar=structLookup(context,rootStruct,fieldPath,false);
      VInfo fieldInfo=currStructVInfo != null ? currStructVInfo.getFieldVInfo(f.getName()) : null;
      arrays.add(Pair.create(fieldVar,fieldInfo));
    }
 else     if (Types.isStruct(f.getType())) {
      VInfo nestedVInfo=currStructVInfo.getFieldVInfo(f.getName());
      findArraysInStructToClose(context,rootStruct,(StructType)f.getType(),nestedVInfo,fieldPath,arrays);
    }
    fieldPath.pop();
  }
}
Program: 132673
Project: 132673
Buggy source:
void findArraysInStruct(Context context,Var root,VInfo structVInfo,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  findArraysInStructToClose(context,root,structVInfo,new StackLite<String>(),arrays);
}

Fixed version (ground truth):
void findArraysInStruct(Context context,Var root,VInfo structVInfo,List<Pair<Var,VInfo>> arrays) throws UndefinedTypeException, UserException {
  assert(Types.isStruct(root));
  findArraysInStructToClose(context,root,(StructType)root.type(),structVInfo,new StackLite<String>(),arrays);
}
Program: 132674
Project: 132674
Buggy source:
/** 
 * Find the type of a particular field
 * @param context
 * @param fieldName
 * @param type a struct or a reference to a struct
 * @return
 * @throws TypeMismatchException if the type isn't a struct or struct ref,or the field doesn't exist in the type
 */
public static Type findStructFieldType(Context context,String fieldName,Type type) throws TypeMismatchException {
  StructType structType;
  if (Types.isStruct(type)) {
    structType=((StructType)type);
  }
 else   if (Types.isStructRef(type)) {
    structType=((StructType)(type.memberType()));
  }
 else {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ type.toString());
  }
  Type fieldType=structType.getFieldTypeByName(fieldName);
  if (fieldType == null) {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ structType.typeName());
  }
  return fieldType;
}

Fixed version (ground truth):
/** 
 * Find the type of a particular field
 * @param context
 * @param fieldName
 * @param type a struct or a reference to a struct
 * @return
 * @throws TypeMismatchException if the type isn't a struct or struct ref,or the field doesn't exist in the type
 */
public static Type findStructFieldType(Context context,String fieldName,Type type) throws TypeMismatchException {
  StructType structType;
  if (Types.isStruct(type)) {
    structType=((StructType)type);
  }
 else   if (Types.isStructRef(type)) {
    structType=((StructType)(type.memberType()));
  }
 else {
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ type.toString());
  }
  Type fieldType=structType.getFieldTypeByName(fieldName);
  if (fieldType == null) {
    new Exception().printStackTrace();
    throw new TypeMismatchException(context,"String_Node_Str" + fieldName + "String_Node_Str"+ structType.typeName()+ "String_Node_Str"+ "String_Node_Str"+ structType.getFields());
  }
  return fieldType;
}
Program: 132675
Project: 132675
Buggy source:
private List<Arg> canonicalizeAssignValue(GlobalConstants consts,ArgCV val){
  if (val.isArrayMemberVal() || val.isArrayMember()) {
    Arg arr=byAlias.findCanonical(val.getInput(0));
    Arg ix=byValue.findCanonical(val.getInput(1));
    return Arrays.asList(arr,ix);
  }
 else   if (val.isStructFieldVal() || val.isStructFieldAlias() || val.isStructFieldCopy()|| val.isStructFieldValRef()) {
    Arg struct=byAlias.findCanonical(val.getInput(0));
    Arg fieldName=byValue.findCanonical(val.getInput(1));
    return Arrays.asList(struct,fieldName);
  }
 else   if (val.isFilenameValCV() || val.isFilenameAliasCV() || val.isLocalFilenameCV()) {
    return Arrays.asList(Arg.createStringLit("String_Node_Str"),byAlias.findCanonical(val.getInput(0)));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + val + "String_Node_Str");
  }
}

Fixed version (ground truth):
private List<Arg> canonicalizeAssignValue(GlobalConstants consts,ArgCV val){
  if (val.isArrayMemberVal() || val.isArrayMember()) {
    Arg arr=byAlias.findCanonical(val.getInput(0));
    Arg ix=byValue.findCanonical(val.getInput(1));
    return Arrays.asList(arr,ix);
  }
 else   if (val.isStructFieldVal() || val.isStructFieldAlias() || val.isStructFieldCopy()|| val.isStructFieldValRef()) {
    List<Arg> inputs=val.getInputs();
    List<Arg> result=new ArrayList<Arg>(inputs.size());
    assert(inputs.size() >= 2);
    Arg struct=inputs.get(0);
    result.add(byAlias.findCanonical(struct));
    for (int i=1; i < inputs.size(); i++) {
      Arg field=inputs.get(i);
      result.add(byValue.findCanonical(field));
    }
    return result;
  }
 else   if (val.isFilenameValCV() || val.isFilenameAliasCV() || val.isLocalFilenameCV()) {
    return Arrays.asList(Arg.createStringLit("String_Node_Str"),byAlias.findCanonical(val.getInput(0)));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + val + "String_Node_Str");
  }
}
Program: 132676
Project: 132676
Buggy source:
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  assert(start.isImmediateFloat());
  assert(end.isImmediateFloat());
  assert(increment.isImmediateFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_ITERSTOTAL);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}

Fixed version (ground truth):
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  assert(start.isImmediateFloat());
  assert(end.isImmediateFloat());
  assert(increment.isImmediateFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_FLOAT_RANGE_ITERMAX);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}
Program: 132677
Project: 132677
Buggy source:
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  assert(start.isImmediateFloat());
  assert(end.isImmediateFloat());
  assert(increment.isImmediateFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_ITERSTOTAL);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.group(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}

Fixed version (ground truth):
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  assert(start.isImmediateFloat());
  assert(end.isImmediateFloat());
  assert(increment.isImmediateFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_ITERSTOTAL);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}
Program: 132678
Project: 132678
Buggy source:
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  assert(start.isImmediateFloat());
  assert(end.isImmediateFloat());
  assert(increment.isImmediateFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_ITERSTOTAL);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}

Fixed version (ground truth):
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,MultiMap<Var,RefCount> constIncrs){
  assert(start.isImmediateFloat());
  assert(end.isImmediateFloat());
  assert(increment.isImmediateFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_FLOAT_RANGE_ITERMAX);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}