nus-yam/ex-repair huggingface dataset:
Program: 133220
Project: 133220
Buggy source:
@Override public void initUpdateable(Var updateable,Arg val){
  assert(Types.isScalarUpdateable(updateable.type()));
  if (!updateable.type().equals(Types.UP_FLOAT)) {
    throw new STCRuntimeError(updateable.type() + "String_Node_Str");
  }
  assert(val.isImmediateFloat());
  pointStack.peek().add(Turbine.floatSet(prefixVar(updateable.name()),opargToExpr(val)));
}

Fixed version (ground truth):
@Override public void initUpdateable(Var updateable,Arg val){
  assert(Types.isScalarUpdateable(updateable.type()));
  if (!updateable.type().equals(Types.UP_FLOAT)) {
    throw new STCRuntimeError(updateable.type() + "String_Node_Str");
  }
  assert(val.isImmediateFloat());
  pointStack.peek().add(Turbine.updateableFloatInit(varToExpr(updateable),opargToExpr(val)));
}
Program: 133221
Project: 133221
Buggy source:
@Override public void assignString(Var target,Arg src){
  assert(src.isImmediateString());
  if (!Types.isString(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.stringSet(prefixVar(target.name()),opargToExpr(src)));
}

Fixed version (ground truth):
@Override public void assignString(Var target,Arg src){
  assert(src.isImmediateString());
  if (!Types.isString(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.stringSet(varToExpr(target),opargToExpr(src)));
}
Program: 133222
Project: 133222
Buggy source:
/** 
 * Set target=addressof(src)
 */
@Override public void assignReference(Var target,Var src){
  assert(Types.isRef(target.type()));
  assert(target.type().memberType().equals(src.type()));
  if (refIsString(target.type())) {
    pointStack.peek().add(Turbine.stringSet(prefixVar(target.name()),varToExpr(src)));
  }
 else {
    pointStack.peek().add(Turbine.integerSet(prefixVar(target.name()),varToExpr(src)));
  }
}

Fixed version (ground truth):
/** 
 * Set target=addressof(src)
 */
@Override public void assignReference(Var target,Var src){
  assert(Types.isRef(target.type()));
  assert(target.type().memberType().equals(src.type()));
  if (refIsString(target.type())) {
    pointStack.peek().add(Turbine.stringSet(varToExpr(target),varToExpr(src)));
  }
 else {
    pointStack.peek().add(Turbine.integerSet(varToExpr(target),varToExpr(src)));
  }
}
Program: 133223
Project: 133223
Buggy source:
@Override public void assignBool(Var target,Arg src){
  assert(src.isImmediateBool());
  if (!Types.isBool(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.integerSet(prefixVar(target.name()),opargToExpr(src)));
}

Fixed version (ground truth):
@Override public void assignBool(Var target,Arg src){
  assert(src.isImmediateBool());
  if (!Types.isBool(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.integerSet(varToExpr(target),opargToExpr(src)));
}
Program: 133224
Project: 133224
Buggy source:
@Override public void addGlobal(String name,Arg val){
  String tclName=prefixVar(name);
  globInit.add(Turbine.makeTCLGlobal(tclName));
  String typePrefix;
  Expression expr;
  Command setCmd;
switch (val.getKind()) {
case INTVAL:
    typePrefix=Turbine.INTEGER_TYPENAME;
  expr=new LiteralInt(val.getIntLit());
setCmd=Turbine.integerSet(tclName,expr);
break;
case FLOATVAL:
typePrefix=Turbine.FLOAT_TYPENAME;
expr=new LiteralFloat(val.getFloatLit());
setCmd=Turbine.floatSet(tclName,expr);
break;
case STRINGVAL:
typePrefix=Turbine.STRING_TYPENAME;
expr=new TclString(val.getStringLit(),true);
setCmd=Turbine.stringSet(tclName,expr);
break;
case BOOLVAL:
typePrefix=Turbine.INTEGER_TYPENAME;
expr=new LiteralInt(val.getBoolLit() ? 1 : 0);
setCmd=Turbine.integerSet(tclName,expr);
break;
default :
throw new STCRuntimeError("String_Node_Str" + val.getKind());
}
globInit.add(Turbine.allocate(tclName,typePrefix,false));
globInit.add(setCmd);
}

Fixed version (ground truth):
@Override public void addGlobal(String name,Arg val){
  String tclName=prefixVar(name);
  Value tclVal=new Value(tclName);
  globInit.add(Turbine.makeTCLGlobal(tclName));
  String typePrefix;
  Expression expr;
  Command setCmd;
switch (val.getKind()) {
case INTVAL:
    typePrefix=Turbine.INTEGER_TYPENAME;
  expr=new LiteralInt(val.getIntLit());
setCmd=Turbine.integerSet(tclVal,expr);
break;
case FLOATVAL:
typePrefix=Turbine.FLOAT_TYPENAME;
expr=new LiteralFloat(val.getFloatLit());
setCmd=Turbine.floatSet(tclVal,expr);
break;
case STRINGVAL:
typePrefix=Turbine.STRING_TYPENAME;
expr=new TclString(val.getStringLit(),true);
setCmd=Turbine.stringSet(tclVal,expr);
break;
case BOOLVAL:
typePrefix=Turbine.INTEGER_TYPENAME;
expr=new LiteralInt(val.getBoolLit() ? 1 : 0);
setCmd=Turbine.integerSet(tclVal,expr);
break;
default :
throw new STCRuntimeError("String_Node_Str" + val.getKind());
}
globInit.add(Turbine.allocate(tclName,typePrefix,false));
globInit.add(setCmd);
}
Program: 133225
Project: 133225
Buggy source:
@Override public void assignFloat(Var target,Arg src){
  assert(src.isImmediateFloat());
  if (!Types.isFloat(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.floatSet(prefixVar(target.name()),opargToExpr(src)));
}

Fixed version (ground truth):
@Override public void assignFloat(Var target,Arg src){
  assert(src.isImmediateFloat());
  if (!Types.isFloat(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.floatSet(varToExpr(target),opargToExpr(src)));
}
Program: 133226
Project: 133226
Buggy source:
/** 
 * Generate and return Tcl from our internal TclTree
 */
@Override public String code(){
  StringBuilder sb=new StringBuilder(10 * 1024);
  try {
    tree.appendTo(sb);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    System.out.println(e.getMessage());
    e.printStackTrace();
    System.out.println("String_Node_Str");
    System.out.println(sb);
    System.out.println("String_Node_Str");
    System.exit(ExitCode.ERROR_INTERNAL.code());
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Generate and return Tcl from  our internal TclTree
 */
@Override public String code(){
  StringBuilder sb=new StringBuilder(10 * 1024);
  try {
    tree.appendTo(sb);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    System.out.println(e.getMessage());
    e.printStackTrace();
    System.out.println("String_Node_Str");
    System.out.println(sb);
    System.out.println("String_Node_Str");
    System.exit(ExitCode.ERROR_INTERNAL.code());
  }
  return sb.toString();
}
Program: 133228
Project: 133228
Buggy source:
/** 
 * @param arrayVar
 * @param memberVar
 * @param loopCountVar counter variable, can be null
 * @param splitDegree
 * @param arrayClosed if true, assume array is already closed
 * @param usedVariables
 * @param keepOpenVars
 */
public abstract void startForeachLoop(Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars);

Fixed version (ground truth):
/** 
 * @param loopName unique name for loop
 * @param arrayVar
 * @param memberVar
 * @param loopCountVar counter variable, can be null
 * @param splitDegree
 * @param arrayClosed if true, assume array is already closed
 * @param usedVariables
 * @param keepOpenVars
 */
public abstract void startForeachLoop(String loopName,Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars);
Program: 133231
Project: 133231
Buggy source:
private void copyArrayByValue(Context context,Var dst,Var src) throws UserException {
  assert(dst.type().equals(src.type()));
  assert(Types.isArray(src.type()));
  LocalContext copyContext=new LocalContext(context);
  Type t=src.type();
  Type memType=Types.getArrayMemberType(t);
  Var member=copyContext.createAliasVariable(memType);
  Var ix=copyContext.createLocalValueVariable(Types.V_INT);
  List<Var> keepOpen=Arrays.asList(dst);
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,keepOpen,WaitMode.DATA_ONLY,TaskMode.LOCAL);
  backend.startForeachLoop(src,member,ix,-1,true,usedVars,keepOpen);
  backend.arrayInsertImm(member,dst,Arg.createVar(ix));
  backend.endForeachLoop(-1,true,usedVars,keepOpen);
  backend.decrWriters(dst);
  backend.endWaitStatement(usedVars,keepOpen);
}

Fixed version (ground truth):
private void copyArrayByValue(Context context,Var dst,Var src) throws UserException {
  assert(dst.type().equals(src.type()));
  assert(Types.isArray(src.type()));
  LocalContext copyContext=new LocalContext(context);
  Type t=src.type();
  Type memType=Types.getArrayMemberType(t);
  Var member=copyContext.createAliasVariable(memType);
  Var ix=copyContext.createLocalValueVariable(Types.V_INT);
  List<Var> keepOpen=Arrays.asList(dst);
  List<Var> usedVars=Arrays.asList(src,dst);
  backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(src),usedVars,keepOpen,WaitMode.DATA_ONLY,TaskMode.LOCAL);
  backend.startForeachLoop(context.getFunctionContext().constructName("String_Node_Str"),src,member,ix,-1,true,usedVars,keepOpen);
  backend.arrayInsertImm(member,dst,Arg.createVar(ix));
  backend.endForeachLoop(-1,true,usedVars,keepOpen);
  backend.decrWriters(dst);
  backend.endWaitStatement(usedVars,keepOpen);
}
Program: 133232
Project: 133232
Buggy source:
@Override public void startForeachLoop(Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars){
  if (!Types.isArray(arrayVar.type())) {
    throw new STCRuntimeError("String_Node_Str" + arrayVar.toString());
  }
  assert(arrayVar.type().memberType().equals(memberVar.type()));
  assert(loopCountVar == null || loopCountVar.type().equals(Types.V_INT));
  ForeachLoop loop=new ForeachLoop(arrayVar,memberVar,loopCountVar,splitDegree,arrayClosed,usedVariables,keepOpenVars);
  currBlock().addContinuation(loop);
  blockStack.push(loop.getLoopBody());
}

Fixed version (ground truth):
@Override public void startForeachLoop(String loopName,Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars){
  if (!Types.isArray(arrayVar.type())) {
    throw new STCRuntimeError("String_Node_Str" + arrayVar.toString());
  }
  assert(arrayVar.type().memberType().equals(memberVar.type()));
  assert(loopCountVar == null || loopCountVar.type().equals(Types.V_INT));
  ForeachLoop loop=new ForeachLoop(loopName,arrayVar,memberVar,loopCountVar,splitDegree,arrayClosed,usedVariables,keepOpenVars);
  currBlock().addContinuation(loop);
  blockStack.push(loop.getLoopBody());
}
Program: 133233
Project: 133233
Buggy source:
public ForeachLoop(Var arrayVar,Var loopVar,Var loopCounterVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars){
  this(new Block(BlockType.FOREACH_BODY),arrayVar,loopVar,loopCounterVar,splitDegree,arrayClosed,usedVariables,keepOpenVars);
}

Fixed version (ground truth):
public ForeachLoop(String loopName,Var arrayVar,Var loopVar,Var loopCounterVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars){
  this(loopName,new Block(BlockType.FOREACH_BODY),arrayVar,loopVar,loopCounterVar,splitDegree,arrayClosed,usedVariables,keepOpenVars);
}
Program: 133235
Project: 133235
Buggy source:
private void startForeachInner(Value arrayContents,Var memberVar,Var loopCountVar,List<Var> usedVariables,List<Var> keepOpenVars,int foreach_num){
  Sequence curr=pointStack.peek();
  boolean haveKeys=loopCountVar != null;
  Sequence loopBody=new Sequence();
  String tclMemberVar=prefixVar(memberVar.name());
  String tclCountVar=haveKeys ? prefixVar(loopCountVar.name()) : null;
  Sequence tclLoop;
  if (haveKeys) {
    tclLoop=new DictFor(new Token(tclCountVar),new Token(tclMemberVar),arrayContents,loopBody);
  }
 else {
    tclLoop=new ForEach(new Token(tclMemberVar),arrayContents,loopBody);
  }
  curr.add(tclLoop);
  pointStack.push(loopBody);
}

Fixed version (ground truth):
private void startForeachInner(Value arrayContents,Var memberVar,Var loopCountVar,List<Var> usedVariables,List<Var> keepOpenVars){
  Sequence curr=pointStack.peek();
  boolean haveKeys=loopCountVar != null;
  Sequence loopBody=new Sequence();
  String tclMemberVar=prefixVar(memberVar.name());
  String tclCountVar=haveKeys ? prefixVar(loopCountVar.name()) : null;
  Sequence tclLoop;
  if (haveKeys) {
    tclLoop=new DictFor(new Token(tclCountVar),new Token(tclMemberVar),arrayContents,loopBody);
  }
 else {
    tclLoop=new ForEach(new Token(tclMemberVar),arrayContents,loopBody);
  }
  curr.add(tclLoop);
  pointStack.push(loopBody);
}
Program: 133237
Project: 133237
Buggy source:
@Override public void startForeachLoop(Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars){
  assert(Types.isArray(arrayVar.type()));
  assert(loopCountVar == null || loopCountVar.type().equals(Types.V_INT));
  if (!arrayClosed) {
    throw new STCRuntimeError("String_Node_Str");
  }
  int foreach_num=foreach_counter++;
  String procName="String_Node_Str" + foreach_num;
  if (!arrayClosed) {
    ArrayList<Var> passIn=new ArrayList<Var>(usedVariables);
    if (!passIn.contains(arrayVar)) {
      passIn.add(arrayVar);
    }
    startAsync(procName,Arrays.asList(arrayVar),passIn,keepOpenVars,TaskMode.LOCAL);
  }
  boolean haveKeys=loopCountVar != null;
  String contentsVar=TCLTMP_ARRAY_CONTENTS;
  if (splitDegree <= 0) {
    pointStack.peek().add(Turbine.containerContents(contentsVar,varToExpr(arrayVar),haveKeys));
  }
 else {
    startForeachSplit(procName,arrayVar,contentsVar,splitDegree,haveKeys,usedVariables,keepOpenVars);
  }
  startForeachInner(new Value(contentsVar),memberVar,loopCountVar,usedVariables,keepOpenVars,foreach_num);
}

Fixed version (ground truth):
@Override public void startForeachLoop(String loopName,Var arrayVar,Var memberVar,Var loopCountVar,int splitDegree,boolean arrayClosed,List<Var> usedVariables,List<Var> keepOpenVars){
  assert(Types.isArray(arrayVar.type()));
  assert(loopCountVar == null || loopCountVar.type().equals(Types.V_INT));
  if (!arrayClosed) {
    throw new STCRuntimeError("String_Node_Str");
  }
  if (!arrayClosed) {
    ArrayList<Var> passIn=new ArrayList<Var>(usedVariables);
    if (!passIn.contains(arrayVar)) {
      passIn.add(arrayVar);
    }
    startAsync(loopName + "String_Node_Str",Arrays.asList(arrayVar),passIn,keepOpenVars,TaskMode.LOCAL);
  }
  boolean haveKeys=loopCountVar != null;
  String contentsVar=TCLTMP_ARRAY_CONTENTS;
  if (splitDegree <= 0) {
    pointStack.peek().add(Turbine.containerContents(contentsVar,varToExpr(arrayVar),haveKeys));
  }
 else {
    startForeachSplit(loopName,arrayVar,contentsVar,splitDegree,haveKeys,usedVariables,keepOpenVars);
  }
  startForeachInner(new Value(contentsVar),memberVar,loopCountVar,usedVariables,keepOpenVars);
}
Program: 133240
Project: 133240
Buggy source:
public Set<String> unneededVars(){
  HashSet<String> toRemove=new HashSet<String>();
  Set<String> stillNeeded=findEssentialVars();
  for (  Var v : getVariables()) {
    if (!stillNeeded.contains(v.name())) {
      toRemove.add(v.name());
    }
  }
  return toRemove;
}

Fixed version (ground truth):
public Set<String> unneededVars(){
  HashSet<String> toRemove=new HashSet<String>();
  Pair<Set<String>,List<List<Var>>> res=findEssentialVars();
  Set<String> stillNeeded=res.val1;
  for (  List<Var> dependentSet : res.val2) {
{
      boolean needed=false;
      for (      Var v : dependentSet) {
        if (stillNeeded.contains(v.name())) {
          needed=true;
          break;
        }
      }
      if (needed) {
        for (        Var v : dependentSet) {
          stillNeeded.add(v.name());
        }
      }
    }
  }
  for (  Var v : getVariables()) {
    if (!stillNeeded.contains(v.name())) {
      toRemove.add(v.name());
    }
  }
  return toRemove;
}
Program: 133241
Project: 133241
Buggy source:
private void findEssentialVars(HashSet<String> stillNeeded){
  for (  Var v : this.getVariables()) {
    if (v.isMapped()) {
      stillNeeded.add(v.name());
      stillNeeded.add(v.mapping().name());
    }
  }
  for (  Instruction i : this.getInstructions()) {
    for (    Arg oa : i.getInputs()) {
      if (oa.isVar()) {
        stillNeeded.add(oa.getVar().name());
      }
    }
    if (i.hasSideEffects()) {
      for (      Var out : i.getOutputs()) {
        stillNeeded.add(out.name());
      }
    }
  }
  for (  Continuation c : this.getContinuations()) {
    for (    Var v : c.requiredVars()) {
      stillNeeded.add(v.name());
    }
    for (    Block b : c.getBlocks()) {
      b.findEssentialVars(stillNeeded);
    }
  }
  for (  CleanupAction a : cleanupActions) {
    if (a.action.writesAliasVar()) {
      stillNeeded.add(a.var.name());
    }
    for (    Arg out : a.action.getInputs()) {
      if (out.isVar()) {
        stillNeeded.add(out.getVar().name());
      }
    }
  }
}

Fixed version (ground truth):
private void findEssentialVars(Set<String> stillNeeded,List<List<Var>> interdependencies){
  for (  Var v : this.getVariables()) {
    if (v.isMapped()) {
      stillNeeded.add(v.name());
      stillNeeded.add(v.mapping().name());
    }
  }
  for (  Instruction i : this.getInstructions()) {
    for (    Arg oa : i.getInputs()) {
      if (oa.isVar()) {
        stillNeeded.add(oa.getVar().name());
      }
    }
    if (i.hasSideEffects()) {
      for (      Var out : i.getOutputs()) {
        stillNeeded.add(out.name());
      }
    }
 else {
      interdependencies.add(i.getOutputs());
    }
  }
  for (  Continuation c : this.getContinuations()) {
    for (    Var v : c.requiredVars()) {
      stillNeeded.add(v.name());
    }
    for (    Block b : c.getBlocks()) {
      b.findEssentialVars(stillNeeded,interdependencies);
    }
  }
  for (  CleanupAction a : cleanupActions) {
    if (a.action.writesAliasVar()) {
      stillNeeded.add(a.var.name());
    }
    for (    Arg out : a.action.getInputs()) {
      if (out.isVar()) {
        stillNeeded.add(out.getVar().name());
      }
    }
  }
}
Program: 133242
Project: 133242
Buggy source:
@Override public Collection<Var> requiredVars(){
  ArrayList<Var> res=new ArrayList<Var>();
  for (  Var c : keepOpenVars) {
    if (c.storage() == VarStorage.ALIAS) {
      res.add(c);
    }
  }
  if (mode == WaitMode.EXPLICIT) {
    for (    Var v : waitVars) {
      res.add(v);
    }
  }
  return res;
}

Fixed version (ground truth):
@Override public Collection<Var> requiredVars(){
  ArrayList<Var> res=new ArrayList<Var>();
  for (  Var c : keepOpenVars) {
    if (c.storage() == VarStorage.ALIAS) {
      res.add(c);
    }
  }
  if (mode == WaitMode.EXPLICIT || mode == WaitMode.TASK_DISPATCH) {
    for (    Var v : waitVars) {
      res.add(v);
    }
  }
  return res;
}
Program: 133243
Project: 133243
Buggy source:
private void foreach(Context context,SwiftAST tree) throws UserException {
  ForeachLoop loop=ForeachLoop.fromAST(context,tree);
  if (loop.iteratesOverRange() && loop.getLoopCountVal() != null) {
    foreachRange(context,loop);
  }
 else {
    foreachArray(context,loop);
  }
}

Fixed version (ground truth):
private void foreach(Context context,SwiftAST tree) throws UserException {
  ForeachLoop loop=ForeachLoop.fromAST(context,tree);
  if (loop.iteratesOverRange() && loop.getCountVarName() == null) {
    foreachRange(context,loop);
  }
 else {
    foreachArray(context,loop);
  }
}
Program: 133244
Project: 133244
Buggy source:
/** 
 * @return the type of the result
 * @throws UserException 
 */
public ExprType getType(Context context) throws UserException {
  List<SwiftAST> members=getMembers();
  if (members.size() == 0) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str");
  }
  List<SwiftType> memberTypes=new ArrayList<SwiftType>(members.size());
  for (  SwiftAST elem : members) {
    memberTypes.add(TypeChecker.findSingleExprType(context,elem));
  }
  List<SwiftType> possibleTypes=TypeChecker.typeIntersection(memberTypes);
  if (possibleTypes.size() == 0) {
    throw new TypeMismatchException(context,"String_Node_Str" + "String_Node_Str" + memberTypes.toString());
  }
  List<SwiftType> possibleArrayTypes=new ArrayList<SwiftType>();
  for (  SwiftType alt : possibleTypes) {
    possibleArrayTypes.add(new ArrayType(alt));
  }
  return new ExprType(UnionType.createUnionType(possibleArrayTypes));
}

Fixed version (ground truth):
/** 
 * @return the type of the result
 * @throws UserException 
 */
public ExprType getType(Context context) throws UserException {
  List<SwiftAST> members=getMembers();
  if (members.size() == 0) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str");
  }
  List<SwiftType> memberTypes=new ArrayList<SwiftType>(members.size());
  for (  SwiftAST elem : members) {
    memberTypes.add(TypeChecker.findSingleExprType(context,elem));
  }
  List<SwiftType> possibleTypes=TypeChecker.typeIntersection(memberTypes);
  if (possibleTypes.size() == 0) {
    throw new TypeMismatchException(context,"String_Node_Str" + "String_Node_Str" + memberTypes.toString());
  }
  List<SwiftType> possibleArrayTypes=new ArrayList<SwiftType>();
  for (  SwiftType alt : possibleTypes) {
    possibleArrayTypes.add(new ArrayType(alt));
  }
  return new ExprType(UnionType.makeUnion(possibleArrayTypes));
}
Program: 133245
Project: 133245
Buggy source:
private static ArgDecl extractArgInfo(Context context,SwiftAST arg) throws UndefinedTypeException, InvalidSyntaxException {
  assert(arg.getType() == ExMParser.DECLARATION);
  assert(arg.getChildCount() == 2 || arg.getChildCount() == 3);
  ArgDecl argInfo;
  boolean thisVarArgs=false;
  if (arg.getChildCount() == 3) {
    assert(arg.child(2).getType() == ExMParser.VARARGS);
    thisVarArgs=true;
  }
  SwiftAST baseTypes=arg.child(0);
  SwiftAST restDecl=arg.child(1);
  assert(baseTypes.getType() == ExMParser.MULTI_TYPE);
  assert(baseTypes.getChildCount() >= 1);
  assert(restDecl.getType() == ExMParser.DECLARE_VARIABLE_REST);
  ArrayList<SwiftType> alts=new ArrayList<SwiftType>(baseTypes.getChildCount());
  String varname=null;
  for (int i=0; i < baseTypes.getChildCount(); i++) {
    SwiftAST typeAlt=baseTypes.child(i);
    assert(typeAlt.getType() == ExMParser.ID);
    String typeName=typeAlt.getText();
    SwiftType baseType=context.lookupType(typeName);
    if (baseType == null) {
      throw new UndefinedTypeException(context,typeName);
    }
    Variable v=fromFormalArgTree(context,baseType,restDecl,DefType.INARG);
    varname=v.getName();
    alts.add(v.getType());
  }
  SwiftType argType=UnionType.createUnionType(alts);
  argInfo=new ArgDecl(varname,argType,thisVarArgs);
  return argInfo;
}

Fixed version (ground truth):
private static ArgDecl extractArgInfo(Context context,SwiftAST arg) throws UndefinedTypeException, InvalidSyntaxException {
  assert(arg.getType() == ExMParser.DECLARATION);
  assert(arg.getChildCount() == 2 || arg.getChildCount() == 3);
  ArgDecl argInfo;
  boolean thisVarArgs=false;
  if (arg.getChildCount() == 3) {
    assert(arg.child(2).getType() == ExMParser.VARARGS);
    thisVarArgs=true;
  }
  SwiftAST baseTypes=arg.child(0);
  SwiftAST restDecl=arg.child(1);
  assert(baseTypes.getType() == ExMParser.MULTI_TYPE);
  assert(baseTypes.getChildCount() >= 1);
  assert(restDecl.getType() == ExMParser.DECLARE_VARIABLE_REST);
  ArrayList<SwiftType> alts=new ArrayList<SwiftType>(baseTypes.getChildCount());
  String varname=null;
  for (int i=0; i < baseTypes.getChildCount(); i++) {
    SwiftAST typeAlt=baseTypes.child(i);
    assert(typeAlt.getType() == ExMParser.ID);
    String typeName=typeAlt.getText();
    SwiftType baseType=context.lookupType(typeName);
    if (baseType == null) {
      throw new UndefinedTypeException(context,typeName);
    }
    Variable v=fromFormalArgTree(context,baseType,restDecl,DefType.INARG);
    varname=v.getName();
    alts.add(v.getType());
  }
  SwiftType argType=UnionType.makeUnion(alts);
  argInfo=new ArgDecl(varname,argType,thisVarArgs);
  return argInfo;
}
Program: 133247
Project: 133247
Buggy source:
/** 
 * Creates a temporary variable and evaluates expression into it
 * @param codebuf buffer to append code to
 * @param type type of tmp variable
 * @return return the name of a newly created tmp variable
 * @throws UserException
 */
public Variable evalExprToTmp(Context context,SwiftAST tree,SwiftType type,boolean storeInStack,Map<String,String> renames) throws UserException {
  assert(type != null);
  if (tree.getType() == ExMParser.VARIABLE) {
    String varName=tree.child(0).getText();
    if (renames != null && renames.containsKey(varName)) {
      varName=renames.get(varName);
    }
    Variable var=context.getDeclaredVariable(varName);
    if (var == null) {
      throw new UndefinedVariableException(context,"String_Node_Str" + varName + "String_Node_Str");
    }
    if (var.getStorage() == VariableStorage.STACK || (!storeInStack) && var.getType().equals(type)) {
      return var;
    }
  }
  if (tree.getType() == ExMParser.ARRAY_LOAD && immediateArrayLoadPossible(tree)) {
    throw new STCRuntimeError("String_Node_Str");
  }
 else   if (tree.getType() == ExMParser.STRUCT_LOAD && Types.isStruct(TypeChecker.findSingleExprType(context,tree.child(0)))) {
    return lookupStructField(context,tree,type,storeInStack,null,renames);
  }
 else {
    Variable tmp=varCreator.createTmp(context,type,storeInStack,false);
    ArrayList<Variable> childOList=new ArrayList<Variable>(1);
    childOList.add(tmp);
    walkExpr(context,tree,childOList,renames);
    return tmp;
  }
}

Fixed version (ground truth):
/** 
 * Creates a temporary variable and evaluates expression into it
 * @param codebuf buffer to append code to
 * @param type type of tmp variable
 * @return return the name of a newly created tmp variable
 * @throws UserException
 */
public Variable evalExprToTmp(Context context,SwiftAST tree,SwiftType type,boolean storeInStack,Map<String,String> renames) throws UserException {
  assert(type != null);
  if (tree.getType() == ExMParser.VARIABLE) {
    String varName=tree.child(0).getText();
    if (renames != null && renames.containsKey(varName)) {
      varName=renames.get(varName);
    }
    Variable var=context.getDeclaredVariable(varName);
    if (var == null) {
      throw new UndefinedVariableException(context,"String_Node_Str" + varName + "String_Node_Str");
    }
    if (var.getStorage() == VariableStorage.STACK || (!storeInStack) && var.getType().equals(type)) {
      return var;
    }
  }
  if (tree.getType() == ExMParser.STRUCT_LOAD && Types.isStruct(TypeChecker.findSingleExprType(context,tree.child(0)))) {
    return lookupStructField(context,tree,type,storeInStack,null,renames);
  }
 else {
    Variable tmp=varCreator.createTmp(context,type,storeInStack,false);
    ArrayList<Variable> childOList=new ArrayList<Variable>(1);
    childOList.add(tmp);
    walkExpr(context,tree,childOList,renames);
    return tmp;
  }
}
Program: 133249
Project: 133249
Buggy source:
private static ExprType callFunction(Context context,SwiftAST tree,boolean noWarn) throws UndefinedFunctionException, UserException {
  FunctionCall f=FunctionCall.fromAST(context,tree);
  List<FunctionType> alts=concretiseFunctionCall(context,f.function(),f.type(),f.args(),noWarn);
  if (alts.size() == 1) {
    return new ExprType(alts.get(0).getOutputs());
  }
 else {
    assert(alts.size() >= 2);
    int numOutputs=f.type().getOutputs().size();
    if (numOutputs == 0) {
      return new ExprType(Collections.<SwiftType>emptyList());
    }
 else {
      List<SwiftType> altOutputs=new ArrayList<SwiftType>();
      for (int out=0; out < numOutputs; out++) {
        List<SwiftType> altOutput=new ArrayList<SwiftType>();
        for (        FunctionType ft : alts) {
          altOutput.add(ft.getOutputs().get(out));
        }
        altOutputs.add(UnionType.createUnionType(altOutput));
      }
      return new ExprType(altOutputs);
    }
  }
}

Fixed version (ground truth):
private static ExprType callFunction(Context context,SwiftAST tree,boolean noWarn) throws UndefinedFunctionException, UserException {
  FunctionCall f=FunctionCall.fromAST(context,tree);
  List<FunctionType> alts=concretiseFunctionCall(context,f.function(),f.type(),f.args(),noWarn);
  if (alts.size() == 1) {
    return new ExprType(alts.get(0).getOutputs());
  }
 else {
    assert(alts.size() >= 2);
    int numOutputs=f.type().getOutputs().size();
    if (numOutputs == 0) {
      return new ExprType(Collections.<SwiftType>emptyList());
    }
 else {
      List<SwiftType> altOutputs=new ArrayList<SwiftType>();
      for (int out=0; out < numOutputs; out++) {
        List<SwiftType> altOutput=new ArrayList<SwiftType>();
        for (        FunctionType ft : alts) {
          altOutput.add(ft.getOutputs().get(out));
        }
        altOutputs.add(UnionType.makeUnion(altOutput));
      }
      return new ExprType(altOutputs);
    }
  }
}
Program: 133250
Project: 133250
Buggy source:
/** 
 * Check function argument type Returns which formal argument type is selected. Only handles case where formalArgT has a type variable
 * @param context
 * @param func
 * @param arg
 * @param formalArgT
 * @param argExprT
 * @param tvConstraints fill in constraints for type variables
 * @return
 * @throws TypeMismatchException
 */
private static SwiftType checkFunArgTV(Context context,String func,int arg,SwiftType formalArgT,SwiftType argExprT,MultiMap<String,SwiftType> tvConstraints) throws TypeMismatchException {
  if (Types.isUnion(formalArgT)) {
    throw new STCRuntimeError("String_Node_Str");
  }
 else   if (Types.isTypeVar(formalArgT)) {
    SwiftType actConv;
    if (Types.isReference(argExprT)) {
      actConv=argExprT.getMemberType();
    }
 else {
      actConv=argExprT;
    }
    tvConstraints.put(formalArgT.getTypeVarName(),actConv);
  }
 else   if ((Types.isArray(formalArgT) || Types.isArray(formalArgT)) && Types.isTypeVar(Types.getArrayMemberType(formalArgT))) {
    if (!Types.isArray(argExprT) && !Types.isArrayRef(argExprT)) {
      throw argumentTypeException(context,arg,formalArgT,argExprT,func);
    }
    tvConstraints.put(Types.getArrayMemberType(formalArgT).getTypeVarName(),Types.getArrayMemberType(argExprT));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + formalArgT);
  }
  return formalArgT;
}

Fixed version (ground truth):
/** 
 * Check function argument type Returns which formal argument type is selected. Only handles case where formalArgT has a type variable
 * @param context
 * @param func
 * @param arg
 * @param formalArgT
 * @param argExprT
 * @param tvConstraints fill in constraints for type variables
 * @return
 * @throws TypeMismatchException
 */
private static SwiftType checkFunArgTV(Context context,String func,int arg,SwiftType formalArgT,SwiftType argExprT,MultiMap<String,SwiftType> tvConstraints) throws TypeMismatchException {
  if (Types.isUnion(formalArgT)) {
    throw new STCRuntimeError("String_Node_Str");
  }
  if (Types.isReference(formalArgT)) {
    argExprT=argExprT.getMemberType();
  }
  if (Types.isUnion(argExprT)) {
    List<Map<String,SwiftType>> possible=new ArrayList<Map<String,SwiftType>>();
    for (    SwiftType alt : UnionType.getAlternatives(argExprT)) {
      possible.add(formalArgT.matchTypeVars(alt));
    }
    for (    Map<String,SwiftType> m : possible) {
      assert(m.keySet().equals(possible.get(0).keySet()));
    }
    for (    String boundVar : possible.get(0).keySet()) {
      List<SwiftType> choices=new ArrayList<SwiftType>();
      for (      Map<String,SwiftType> m : possible) {
        SwiftType t=m.get(boundVar);
        assert(!Types.isUnion(t));
        choices.add(t);
      }
      tvConstraints.put(boundVar,UnionType.makeUnion(choices));
    }
  }
 else {
    tvConstraints.putAll(formalArgT.matchTypeVars(argExprT));
  }
  return formalArgT;
}
Program: 133251
Project: 133251
Buggy source:
private static ExprType findOperatorResultType(Context context,SwiftAST tree) throws TypeMismatchException, UserException {
  String opName=extractOpName(tree);
  ArrayList<SwiftType> argTypes=new ArrayList<SwiftType>();
  List<BuiltinOpcode> opcodes=getBuiltInFromOpTree(context,tree,argTypes);
  assert(opcodes != null);
  assert(opcodes.size() > 0);
  List<SwiftType> alternatives=new ArrayList<SwiftType>(opcodes.size());
  for (  BuiltinOpcode opcode : opcodes) {
    OpType opType=Operators.getBuiltinOpType(opcode);
    assert(opType != null);
    checkOp(context,opName,opType,argTypes);
    alternatives.add(new ScalarFutureType(opType.out));
  }
  return new ExprType(UnionType.createUnionType(alternatives));
}

Fixed version (ground truth):
private static ExprType findOperatorResultType(Context context,SwiftAST tree) throws TypeMismatchException, UserException {
  String opName=extractOpName(tree);
  ArrayList<SwiftType> argTypes=new ArrayList<SwiftType>();
  List<BuiltinOpcode> opcodes=getBuiltInFromOpTree(context,tree,argTypes);
  assert(opcodes != null);
  assert(opcodes.size() > 0);
  List<SwiftType> alternatives=new ArrayList<SwiftType>(opcodes.size());
  for (  BuiltinOpcode opcode : opcodes) {
    OpType opType=Operators.getBuiltinOpType(opcode);
    assert(opType != null);
    checkOp(context,opName,opType,argTypes);
    alternatives.add(new ScalarFutureType(opType.out));
  }
  return new ExprType(UnionType.makeUnion(alternatives));
}
Program: 133252
Project: 133252
Buggy source:
/** 
 * The type of the internal variable that will be created from an array dereference
 * @param memberType the type of array memebrs for the array being dereferenced
 * @return
 */
private static SwiftType dereferenceResultType(SwiftType memberType){
  SwiftType resultType;
  if (Types.isScalarFuture(memberType)) {
    resultType=memberType;
  }
 else   if (Types.isArray(memberType) || Types.isStruct(memberType)) {
    resultType=new ReferenceType(memberType);
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + memberType.toString());
  }
  return resultType;
}

Fixed version (ground truth):
/** 
 * The type of the internal variable that will be created from an array dereference
 * @param memberType the type of array memebrs for the array being dereferenced
 * @return
 */
public static SwiftType dereferenceResultType(SwiftType memberType){
  SwiftType resultType;
  if (Types.isScalarFuture(memberType)) {
    resultType=memberType;
  }
 else   if (Types.isArray(memberType) || Types.isStruct(memberType)) {
    resultType=new ReferenceType(memberType);
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + memberType.toString());
  }
  return resultType;
}
Program: 133254
Project: 133254
Buggy source:
/** 
 * Creates a new tmp value, entering it in the provided context and calling the backend to initialise it 
 * @param context
 * @param type
 * @param storeInStack if the variable should be stored in the stack
 * @param isAlias if the variable is just going to be an alias for anothervariable (i.e. no storage should be declared)
 * @return
 * @throws UserException
 * @throws UndefinedTypeException
 */
public Variable createTmp(Context context,SwiftType type,boolean storeInStack,boolean isAlias) throws UserException, UndefinedTypeException {
  if (storeInStack && isAlias) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str");
  }
  Variable tmp;
  if ((!storeInStack) && isAlias) {
    tmp=context.createAliasVariable(type);
  }
 else {
    tmp=context.createTmpVar(type,storeInStack);
  }
  initialiseVariable(context,tmp);
  return tmp;
}

Fixed version (ground truth):
/** 
 * Creates a new tmp value, entering it in the provided context and calling the backend to initialise it 
 * @param context
 * @param type
 * @param storeInStack if the variable should be stored in the stack
 * @param isAlias if the variable is just going to be an alias for anothervariable (i.e. no storage should be declared)
 * @return
 * @throws UserException
 * @throws UndefinedTypeException
 */
public Variable createTmp(Context context,SwiftType type,boolean storeInStack,boolean isAlias) throws UserException, UndefinedTypeException {
  assert(context != null);
  if (storeInStack && isAlias) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str");
  }
  Variable tmp;
  if ((!storeInStack) && isAlias) {
    tmp=context.createAliasVariable(type);
  }
 else {
    tmp=context.createTmpVar(type,storeInStack);
  }
  initialiseVariable(context,tmp);
  return tmp;
}
Program: 133255
Project: 133255
Buggy source:
/** 
 * Get asynchronous implementation of builtin op TODO: this is a temporary solution to get this working. Will be better later on to have arith ops, etc in  different namespace entirely
 * @throws UserException 
 */
public static String getBuiltinOpImpl(BuiltinOpcode op){
  String impl=builtinOpImpls.get(op);
  if (impl != null) {
    return impl;
  }
  List<String> impls=FunctionSemantics.findOpImpl(op);
  assert(impls != null);
  assert(impls.size() > 0);
  if (impls.size() > 1) {
    Logger.getLogger("String_Node_Str").warn("String_Node_Str" + op + "String_Node_Str"+ impls.toString());
  }
  return impls.get(0);
}

Fixed version (ground truth):
/** 
 * Get asynchronous implementation of builtin op TODO: this is a temporary solution to get this working. Will be better later on to have arith ops, etc in  different namespace entirely
 * @throws UserException 
 */
public static TclFunRef getBuiltinOpImpl(BuiltinOpcode op){
  TclFunRef impl=builtinOpImpls.get(op);
  if (impl != null) {
    return impl;
  }
  return null;
}
Program: 133257
Project: 133257
Buggy source:
@Override public void asyncOp(BuiltinOpcode op,Variable out,List<Arg> in,Arg priority){
  String fnName=BuiltinOps.getBuiltinOpImpl(op);
  if (fnName == null) {
    throw new STCRuntimeError("String_Node_Str" + op + "String_Node_Str");
  }
  ArrayList<Variable> inputs=new ArrayList<Variable>();
  for (  Arg a : in) {
    assert(a.getType() == ArgType.VAR);
    inputs.add(a.getVar());
  }
  builtinFunctionCall(fnName,inputs,Arrays.asList(out),priority);
}

Fixed version (ground truth):
@Override public void asyncOp(BuiltinOpcode op,Variable out,List<Arg> in,Arg priority){
  TclFunRef fn=BuiltinOps.getBuiltinOpImpl(op);
  if (fn == null) {
    List<String> impls=FunctionSemantics.findOpImpl(op);
    assert(impls != null);
    assert(impls.size() > 0);
    if (impls.size() > 1) {
      Logger.getLogger("String_Node_Str").warn("String_Node_Str" + op + "String_Node_Str"+ impls.toString());
    }
    fn=builtinSymbols.get(impls.get(0));
  }
  ArrayList<Variable> inputs=new ArrayList<Variable>();
  for (  Arg a : in) {
    assert(a.getType() == ArgType.VAR);
    inputs.add(a.getVar());
  }
  List<Variable> outL=(out == null) ? new ArrayList<Variable>(0) : Arrays.asList(out);
  builtinFunctionCall("String_Node_Str" + op.toString(),fn,inputs,outL,priority);
}
Program: 133258
Project: 133258
Buggy source:
@Override public void defineBuiltinFunction(String name,String pkg,String version,String symbol,FunctionType type,TclOpTemplate inlineTclTemplate){
  String pv=pkg + version;
  if (!pkg.equals("String_Node_Str")) {
    if (!requiredPackages.contains(pv)) {
      PackageRequire pr=new PackageRequire(pkg,version);
      pointStack.peek().add(pr);
      requiredPackages.add(pv);
      pointStack.peek().add(new Command("String_Node_Str"));
    }
  }
  builtinSymbols.put(name,new TCLFunRef(pkg,symbol));
  logger.debug("String_Node_Str" + name);
}

Fixed version (ground truth):
@Override public void defineBuiltinFunction(String name,String pkg,String version,String symbol,FunctionType type,TclOpTemplate inlineTclTemplate){
  String pv=pkg + version;
  if (!pkg.equals("String_Node_Str")) {
    if (!requiredPackages.contains(pv)) {
      PackageRequire pr=new PackageRequire(pkg,version);
      pointStack.peek().add(pr);
      requiredPackages.add(pv);
      pointStack.peek().add(new Command("String_Node_Str"));
    }
  }
  builtinSymbols.put(name,new TclFunRef(pkg,symbol));
  logger.debug("String_Node_Str" + name);
}
Program: 133259
Project: 133259
Buggy source:
@Override public void builtinFunctionCall(String function,List<Variable> inputs,List<Variable> outputs,Arg priority){
  assert(priority == null || priority.isImmediateInt());
  logger.debug("String_Node_Str" + function);
  TclList iList=tclListOfVariables(inputs);
  TclList oList=tclListOfVariables(outputs);
  TCLFunRef tclf=builtinSymbols.get(function);
  if (tclf == null) {
    throw new STCRuntimeError("String_Node_Str" + function);
  }
  Token f=new Token(tclf.pkg + "String_Node_Str" + tclf.symbol);
  Value s=new Value(Turbine.LOCAL_STACK_NAME);
  Command c=new Command(f,s,oList,iList);
  setPriority(priority);
  pointStack.peek().add(c);
  clearPriority(priority);
}

Fixed version (ground truth):
private void builtinFunctionCall(String function,TclFunRef tclf,List<Variable> inputs,List<Variable> outputs,Arg priority){
  TclList iList=tclListOfVariables(inputs);
  TclList oList=tclListOfVariables(outputs);
  if (tclf == null) {
    throw new STCRuntimeError("String_Node_Str" + function);
  }
  Token f=new Token(tclf.pkg + "String_Node_Str" + tclf.symbol);
  Value s=new Value(Turbine.LOCAL_STACK_NAME);
  Command c=new Command(f,s,oList,iList);
  setPriority(priority);
  pointStack.peek().add(c);
  clearPriority(priority);
}
Program: 133260
Project: 133260
Buggy source:
/** 
 * Internal helper to implement constructs that need to wait for a number of variables, and then run some code
 * @param procName
 * @param waitVars
 * @param usedVariables
 * @param containersToRegister
 * @param shareWork if true, work will be shared with other rule enginesat the cost of higher overhead
 */
private void startAsync(String procName,List<Variable> waitVars,List<Variable> usedVariables,List<Variable> containersToRegister,boolean shareWork){
  List<String> args=new ArrayList<String>();
  args.add(Turbine.LOCAL_STACK_NAME);
  for (  Variable v : usedVariables) {
    args.add(prefixVar(v.getName()));
  }
  Sequence constructProc=new Sequence();
  String uniqueName=uniqueTCLFunctionName(procName);
  Proc proc=new Proc(uniqueName,usedTclFunctionNames,args,constructProc);
  tree.add(proc);
  List<Value> inputs=new ArrayList<Value>();
  for (  Variable w : waitVars) {
    inputs.add(varToExpr(w));
  }
  for (  Variable c : containersToRegister) {
    pointStack.peek().add(Turbine.containerSlotCreate(varToExpr(c)));
  }
  TclList action=buildAction(uniqueName,usedVariables);
  pointStack.peek().add(Turbine.rule(uniqueName,inputs,action,shareWork));
  pointStack.push(constructProc);
}

Fixed version (ground truth):
/** 
 * Internal helper to implement constructs that need to wait for a number of variables, and then run some code
 * @param procName
 * @param waitVars
 * @param usedVariables
 * @param containersToRegister
 * @param shareWork if true, work will be shared with other rule enginesat the cost of higher overhead
 */
private void startAsync(String procName,List<Variable> waitVars,List<Variable> usedVariables,List<Variable> containersToRegister,boolean shareWork){
  ArrayList<Variable> toPassIn=new ArrayList<Variable>();
  HashSet<String> alreadyInSet=new HashSet<String>();
  for (  Variable v : usedVariables) {
    toPassIn.add(v);
    alreadyInSet.add(v.getName());
  }
  for (  Variable v : containersToRegister) {
    if (!alreadyInSet.contains(v.getName())) {
      toPassIn.add(v);
    }
  }
  List<String> args=new ArrayList<String>();
  args.add(Turbine.LOCAL_STACK_NAME);
  for (  Variable v : toPassIn) {
    args.add(prefixVar(v.getName()));
  }
  Sequence constructProc=new Sequence();
  String uniqueName=uniqueTCLFunctionName(procName);
  Proc proc=new Proc(uniqueName,usedTclFunctionNames,args,constructProc);
  tree.add(proc);
  List<Value> inputs=new ArrayList<Value>();
  for (  Variable w : waitVars) {
    inputs.add(varToExpr(w));
  }
  for (  Variable c : containersToRegister) {
    pointStack.peek().add(Turbine.containerSlotCreate(varToExpr(c)));
  }
  TclList action=buildAction(uniqueName,toPassIn);
  pointStack.peek().add(Turbine.rule(uniqueName,inputs,action,shareWork));
  pointStack.push(constructProc);
}
Program: 133262
Project: 133262
Buggy source:
/** 
 * Replace variables by name in list Remove variables with duplicate names
 * @param replacements
 * @param vars
 */
public static void replaceVarsInList(Map<String,Oparg> replacements,List<Variable> vars,boolean removeDupes){
  ArrayList<String> alreadySeen=null;
  if (removeDupes) {
    alreadySeen=new ArrayList<String>(vars.size());
  }
  int n=vars.size();
  for (int i=0; i < n; i++) {
    String varName=vars.get(i).getName();
    if (replacements.containsKey(varName)) {
      Oparg oa=replacements.get(varName);
      if (oa.getType() == OpargType.VAR) {
        if (removeDupes && alreadySeen.contains(oa.getVar().getName())) {
          vars.remove(i);
          i--;
          n--;
        }
 else {
          vars.set(i,oa.getVar());
          if (removeDupes) {
            alreadySeen.add(oa.getVar().getName());
          }
        }
      }
    }
 else {
      if (removeDupes) {
        if (alreadySeen.contains(varName)) {
          vars.remove(i);
          i--;
          n--;
        }
 else {
          alreadySeen.add(varName);
        }
      }
    }
  }
}

Fixed version (ground truth):
public static void replaceVarsInList(Map<String,Oparg> replacements,List<Variable> vars,boolean removeDupes,boolean removeMapped){
  ArrayList<String> alreadySeen=null;
  if (removeDupes) {
    alreadySeen=new ArrayList<String>(vars.size());
  }
  ListIterator<Variable> it=vars.listIterator();
  while (it.hasNext()) {
    Variable v=it.next();
    String varName=v.getName();
    if (replacements.containsKey(varName)) {
      Oparg oa=replacements.get(varName);
      if (oa.getType() == OpargType.VAR) {
        if (removeDupes && alreadySeen.contains(oa.getVar().getName())) {
          it.remove();
        }
 else {
          it.set(oa.getVar());
          if (removeDupes) {
            alreadySeen.add(oa.getVar().getName());
          }
        }
      }
    }
 else {
      if (removeDupes) {
        if (alreadySeen.contains(varName)) {
          it.remove();
        }
 else {
          alreadySeen.add(varName);
        }
      }
    }
  }
}