nus-yam/ex-repair huggingface dataset:
Program: 132911
Project: 132911
Buggy source:
public static Instruction arrayCreateNestedImm(Var arrayResult,Var arrayVar,Arg arrIx){
  assert(arrIx.isImmediateInt());
  assert(arrayResult.storage() == VarStorage.ALIAS);
  return new TurbineOp(Opcode.ARRAY_CREATE_NESTED_IMM,Arg.createVar(arrayResult),Arg.createVar(arrayVar),arrIx,Arg.ZERO,Arg.ZERO);
}

Fixed version (ground truth):
public static Instruction arrayCreateNestedImm(Var arrayResult,Var arrayVar,Arg arrIx){
  assert(Types.isArrayKeyVal(arrayVar,arrIx));
  assert(arrayResult.storage() == VarStorage.ALIAS);
  return new TurbineOp(Opcode.ARRAY_CREATE_NESTED_IMM,Arg.createVar(arrayResult),Arg.createVar(arrayVar),arrIx,Arg.ZERO,Arg.ZERO);
}
Program: 132912
Project: 132912
Buggy source:
public static Instruction arrayCreateNestedComputed(Var arrayResult,Var array,Var ix){
  assert(Types.isArrayRef(arrayResult.type()));
  assert(arrayResult.storage() != VarStorage.ALIAS);
  assert(Types.isArray(array.type()));
  assert(Types.isInt(ix.type()));
  return new TurbineOp(Opcode.ARRAY_CREATE_NESTED_FUTURE,Arg.createVar(arrayResult),Arg.createVar(array),Arg.createVar(ix));
}

Fixed version (ground truth):
public static Instruction arrayCreateNestedComputed(Var arrayResult,Var array,Var ix){
  assert(Types.isArrayRef(arrayResult.type()));
  assert(arrayResult.storage() != VarStorage.ALIAS);
  assert(Types.isArray(array.type()));
  assert(Types.isArrayKeyFuture(array,ix));
  return new TurbineOp(Opcode.ARRAY_CREATE_NESTED_FUTURE,Arg.createVar(arrayResult),Arg.createVar(array),Arg.createVar(ix));
}
Program: 132913
Project: 132913
Buggy source:
/** 
 * Check that for loop is sensible semantically
 */
public void validateInit(Context context) throws UserException {
  for (  LoopVar lv : loopVars) {
    Var v=lv.var;
    Var outerV=context.lookupVarUser(v.name());
    if (lv.declaredOutsideLoop) {
      if (outerV == null) {
        throw UndefinedVarError.fromName(context,v.name(),"String_Node_Str" + "String_Node_Str");
      }
    }
 else {
      context.checkNotDefined(v.name());
    }
    SwiftAST initExpr=initExprs.get(v.name());
    if (initExpr == null) {
      throw new UserException(context,"String_Node_Str" + v.name() + "String_Node_Str");
    }
    Type initExprType=TypeChecker.findSingleExprType(context,initExpr);
    TypeChecker.checkAssignment(context,initExprType,v.type(),v.name());
  }
}

Fixed version (ground truth):
/** 
 * Check that for loop is sensible semantically
 */
public void validateInit(Context context) throws UserException {
  for (  LoopVar lv : loopVars) {
    Var v=lv.var;
    Var outerV=context.lookupVarUnsafe(v.name());
    if (lv.declaredOutsideLoop) {
      if (outerV == null) {
        throw UndefinedVarError.fromName(context,v.name(),"String_Node_Str" + "String_Node_Str");
      }
    }
 else {
      context.checkNotDefined(v.name());
    }
    SwiftAST initExpr=initExprs.get(v.name());
    if (initExpr == null) {
      throw new UserException(context,"String_Node_Str" + v.name() + "String_Node_Str");
    }
    Type initExprType=TypeChecker.findSingleExprType(context,initExpr);
    TypeChecker.checkAssignment(context,initExprType,v.type(),v.name());
  }
}
Program: 132914
Project: 132914
Buggy source:
/** 
 * Create dereferenced variable given a reference
 */
public static Var createDerefTmp(Var ref,VarStorage storage){
  assert(Types.isRef(ref.type()));
  Var res=new Var(ref.type().memberType(),DEREF_COMPILER_VAR_PREFIX + ref.name(),storage,DefType.LOCAL_COMPILER,null);
  assert(Types.isRefTo(ref.type(),res.type()));
  return res;
}

Fixed version (ground truth):
/** 
 * Create dereferenced variable given a reference
 */
public static Var createDerefTmp(Var ref,VarStorage storage){
  assert(Types.isRef(ref.type()));
  Var res=new Var(ref.type().memberType(),DEREF_COMPILER_VAR_PREFIX + ref.name(),storage,DefType.LOCAL_COMPILER,null);
  assert(Types.isAssignableRefTo(ref.type(),res.type()));
  return res;
}
Program: 132918
Project: 132918
Buggy source:
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,lookupResult,outVar,outVar.type());
      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.isAssignableRefTo(lookupResult.type(),outVar.type())) {
      dereference(context,outVar,lookupResult);
      return outVar;
    }
 else {
      copyByValue(context,lookupResult,outVar,outVar.type());
      return outVar;
    }
  }
 catch (  RuntimeException e) {
    Logging.getSTCLogger().debug("String_Node_Str" + lookupResult + "String_Node_Str"+ outVar);
    throw e;
  }
}
Program: 132919
Project: 132919
Buggy source:
/** 
 * Generate code for a call to a function, where the arguments might be expressions
 * @param context
 * @param tree
 * @param oList
 * @throws UserException
 * @throws UndefinedVariableException
 * @throws UndefinedFunctionException
 */
private void callFunctionExpression(Context context,SwiftAST tree,List<Var> oList,Map<String,String> renames) throws UserException {
}

Fixed version (ground truth):
/** 
 * Generate code for a call to a function, where the arguments might be expressions
 * @param context
 * @param tree
 * @param oList
 * @throws UserException
 * @throws UndefinedVariableException
 * @throws UndefinedFunctionException
 */
private void callFunctionExpression(Context context,SwiftAST tree,List<Var> oList,Map<String,String> renames) throws UserException {
  assert(tree.getType() == ExMParser.CALL_FUNCTION);
  FunctionCall f=FunctionCall.fromAST(context,tree,true);
  FunctionType concrete=TypeChecker.concretiseFunctionCall(context,f.function(),f.type(),f.args(),oList,false);
  try {
    if (Builtins.isAssertVariant(f.function()) && Settings.getBoolean(Settings.OPT_DISABLE_ASSERTS)) {
      return;
    }
  }
 catch (  InvalidOptionException e) {
    throw new STCRuntimeError("String_Node_Str" + e.toString());
  }
  ArrayList<Var> argVars=new ArrayList<Var>(f.args().size());
  for (int i=0; i < f.args().size(); i++) {
    SwiftAST argtree=f.args().get(i);
    Type expType=concrete.getInputs().get(i);
    Type exprType=TypeChecker.findSingleExprType(context,argtree);
    Type argType=TypeChecker.checkFunArg(context,f.function(),i,expType,exprType).val2;
    argVars.add(eval(context,argtree,argType,false,renames));
  }
  TaskProps propVals=new TaskProps();
  boolean openedWait=false;
  Context callContext=context;
  if (!f.annotations().isEmpty()) {
    List<Pair<TaskPropKey,Var>> propFutures=new ArrayList<Pair<TaskPropKey,Var>>();
    List<Var> waitVars=new ArrayList<Var>();
    for (    TaskPropKey ann : f.annotations().keySet()) {
      checkCallAnnotation(context,f,ann);
      SwiftAST expr=f.annotations().get(ann);
      Type exprType=TypeChecker.findSingleExprType(callContext,expr);
      Type concreteType=TaskProp.checkFrontendType(callContext,ann,exprType);
      Var future=eval(context,expr,concreteType,false,renames);
      waitVars.add(future);
      propFutures.add(Pair.create(ann,future));
    }
    backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),waitVars,WaitMode.WAIT_ONLY,false,false,TaskMode.LOCAL_CONTROL);
    openedWait=true;
    callContext=new LocalContext(context);
    for (    Pair<TaskPropKey,Var> x : propFutures) {
      Var value=varCreator.fetchValueOf(callContext,x.val2);
      propVals.put(x.val1,value.asArg());
    }
  }
  callFunction(context,f.function(),concrete,oList,argVars,propVals);
  if (openedWait) {
    backend.endWaitStatement();
  }
}
Program: 132920
Project: 132920
Buggy source:
/** 
 * Check if an expression type can be used for function argument
 * @param argType non-polymorphic function argument type
 * @param exprType type of argument expression
 * @return true if compatible
 */
public static boolean compatibleArgTypes(Type argType,Type exprType){
  if (exprType.assignableTo(argType)) {
    return true;
  }
 else   if (Types.isRefTo(exprType,argType)) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Check if an expression type can be used for function argument
 * @param argType non-polymorphic function argument type
 * @param exprType type of argument expression
 * @return concretized argType if compatible, null if incompatible
 */
public static Type compatibleArgTypes(Type argType,Type exprType){
  if (exprType.assignableTo(argType)) {
    return exprType.concretize(argType);
  }
 else   if (Types.isAssignableRefTo(exprType,argType)) {
    return exprType.concretize(new RefType(argType));
  }
 else {
    return null;
  }
}
Program: 132921
Project: 132921
Buggy source:
/** 
 * @param formalArgT
 * @param argExprT
 * @return (selected type of argument, selected type of variable)
 */
public static Pair<Type,Type> whichAlternativeType(Type formalArgT,Type argExprT){
  for (  Type argExprAlt : UnionType.getAlternatives(argExprT)) {
    for (    Type formalArgAlt : UnionType.getAlternatives(formalArgT)) {
      if (compatibleArgTypes(formalArgAlt,argExprAlt)) {
        return Pair.create(formalArgAlt,argExprAlt);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @param formalArgT
 * @param argExprT
 * @return (selected type of argument, selected type of variable)
 */
public static Pair<Type,Type> whichAlternativeType(Type formalArgT,Type argExprT){
  for (  Type argExprAlt : UnionType.getAlternatives(argExprT)) {
    for (    Type formalArgAlt : UnionType.getAlternatives(formalArgT)) {
      Type concreteArgType=compatibleArgTypes(formalArgAlt,argExprAlt);
      if (concreteArgType != null) {
        return Pair.create(formalArgAlt,concreteArgType);
      }
    }
  }
  return null;
}
Program: 132922
Project: 132922
Buggy source:
public String toString(){
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  int written=writeContents(sb,true);
  HierarchicalMap<K,V> ancestor=parent;
  while (ancestor != null) {
    ancestor.writeContents(sb,written == 0);
    ancestor=ancestor.parent;
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  int written=writeContents(sb,true);
  HierarchicalMap<K,V> ancestor=parent;
  while (ancestor != null) {
    written+=ancestor.writeContents(sb,written == 0);
    ancestor=ancestor.parent;
  }
  sb.append("String_Node_Str");
  return sb.toString();
}
Program: 132923
Project: 132923
Buggy source:
/** 
 * @param logger
 * @param f
 * @param execCx
 * @param block
 * @param stmts
 * @param cv
 * @param replaceInputs
 * @param replaceAll
 * @return true if inlined. Returns immediately if inlining happens
 * @throws InvalidWriteException
 * @throws InvalidOptionException
 */
private boolean handleStatements(Logger logger,Program program,Function f,ExecContext execCx,Block block,ListIterator<Statement> stmts,ValueTracker cv,HierarchicalMap<Var,Arg> replaceInputs,HierarchicalMap<Var,Arg> replaceAll) throws InvalidWriteException, InvalidOptionException {
  while (stmts.hasNext()) {
    Statement stmt=stmts.next();
    if (stmt.type() == StatementType.INSTRUCTION) {
      handleInstruction(logger,f,execCx,block,stmts,stmt.instruction(),cv,replaceInputs,replaceAll);
    }
 else {
      assert(stmt.type() == StatementType.CONDITIONAL);
      UnifiedState condClosed=recurseOnContinuation(logger,program,f,execCx,stmt.conditional(),cv,replaceInputs,replaceAll);
      cv.addClosed(condClosed);
      cv.addComputedValues(condClosed.availableVals,Ternary.FALSE);
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param logger
 * @param f
 * @param execCx
 * @param block
 * @param stmts
 * @param cv
 * @param replaceInputs
 * @param replaceAll
 * @throws InvalidWriteException
 * @throws InvalidOptionException
 */
private void handleStatements(Logger logger,Program program,Function f,ExecContext execCx,Block block,ListIterator<Statement> stmts,ValueTracker cv,HierarchicalMap<Var,Arg> replaceInputs,HierarchicalMap<Var,Arg> replaceAll) throws InvalidWriteException, InvalidOptionException {
  logger.trace("String_Node_Str");
  StringBuilder sb=new StringBuilder();
  for (  Statement stmt : block.getStatements()) {
    stmt.prettyPrint(sb,"String_Node_Str");
  }
  logger.trace(sb);
  while (stmts.hasNext()) {
    Statement stmt=stmts.next();
    if (stmt.type() == StatementType.INSTRUCTION) {
      handleInstruction(logger,f,execCx,block,stmts,stmt.instruction(),cv,replaceInputs,replaceAll);
    }
 else {
      assert(stmt.type() == StatementType.CONDITIONAL);
      UnifiedState condClosed=recurseOnContinuation(logger,program,f,execCx,stmt.conditional(),cv,replaceInputs,replaceAll);
      cv.addClosed(condClosed);
      cv.addComputedValues(condClosed.availableVals,Ternary.FALSE);
    }
  }
  logger.trace("String_Node_Str");
  sb=new StringBuilder();
  for (  Statement stmt : block.getStatements()) {
    stmt.prettyPrint(sb,"String_Node_Str");
  }
  logger.trace(sb);
}
Program: 132926
Project: 132926
Buggy source:
private static void compileTimeAssertCheck(BuiltinOpcode subop2,List<Arg> inputs2,Map<Var,Arg> knownConstants,String enclosingFnName){
  List<Arg> inputVals=new ArrayList<Arg>(inputs2.size());
  for (  Arg input : inputs2) {
    if (input.isConstant()) {
      inputVals.add(input);
    }
 else     if (knownConstants.containsKey(input.getVar())) {
      inputVals.add(input);
    }
 else {
      return;
    }
  }
  if (subop2 == BuiltinOpcode.ASSERT) {
    Arg cond=inputVals.get(0);
    assert(cond.isBoolVal());
    if (!cond.getBoolLit()) {
      compileTimeAssertWarn(enclosingFnName,"String_Node_Str",inputs2.get(1),knownConstants);
    }
  }
 else {
    assert(subop2 == BuiltinOpcode.ASSERT_EQ);
    Arg a1=inputVals.get(0);
    Arg a2=inputVals.get(1);
    assert(a1.isConstant());
    assert(a2.isConstant());
    if (a1 != null && a2 != null) {
      if (!a1.equals(a2)) {
        String reason=a1.toString() + "String_Node_Str" + a2.toString();
        Arg msg=inputVals.get(2);
        compileTimeAssertWarn(enclosingFnName,reason,msg,knownConstants);
      }
    }
  }
}

Fixed version (ground truth):
private static void compileTimeAssertCheck(BuiltinOpcode subop2,List<Arg> inputs2,Map<Var,Arg> knownConstants,String enclosingFnName){
}
Program: 132927
Project: 132927
Buggy source:
/** 
 * Remove from candidates any variables that can't have the refcount decremented before this instruction executes
 * @param inst
 * @param type
 * @param candidates
 */
private void removeDecrCandidates(Instruction inst,RefCountType type,Set<Var> candidates){
  if (type == RefCountType.READERS) {
    for (    Arg in : inst.getInputs()) {
      if (in.isVar())       candidates.remove(in.getVar());
    }
    for (    Var read : inst.getReadOutputs()) {
      candidates.remove(read);
    }
  }
 else {
    assert(type == RefCountType.WRITERS);
    for (    Var modified : inst.getOutputs()) {
      candidates.remove(modified);
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove from candidates any variables that can't have the refcount decremented before this instruction executes
 * @param inst
 * @param type
 * @param candidates
 */
private void removeDecrCandidates(Instruction inst,RefCountType type,Set<Var> candidates){
  if (type == RefCountType.READERS) {
    for (    Arg in : inst.getInputs()) {
      if (in.isVar())       candidates.remove(in.getVar());
    }
    for (    Var read : inst.getReadOutputs(functionMap)) {
      candidates.remove(read);
    }
  }
 else {
    assert(type == RefCountType.WRITERS);
    for (    Var modified : inst.getOutputs()) {
      candidates.remove(modified);
    }
  }
}
Program: 132928
Project: 132928
Buggy source:
/** 
 * @return list of outputs for which previous value is read
 */
public List<Var> getReadOutputs(){
switch (op) {
case ARRAY_CREATE_NESTED_IMM:
case ARRAY_CREATE_NESTED_FUTURE:
    return Arrays.asList(getOutput(1));
case ARRAYREF_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
  return Arrays.asList(getOutput(2));
default :
return Var.NONE;
}
}

Fixed version (ground truth):
@Override public List<Var> getReadOutputs(Map<String,Function> fns){
switch (op) {
case CALL_BUILTIN:
{
      List<Var> res=new ArrayList<Var>();
      for (      Var o : outputs) {
        if (Types.hasReadableSideChannel(o.type())) {
          res.add(o);
        }
      }
      return res;
    }
case CALL_LOCAL:
case CALL_LOCAL_CONTROL:
case CALL_SYNC:
case CALL_CONTROL:
{
    List<Var> res=new ArrayList<Var>();
    Function f=fns == null ? null : fns.get(this.functionName);
    for (int i=0; i < outputs.size(); i++) {
      Var o=outputs.get(i);
      if (Types.hasReadableSideChannel(o.type()) && (f == null || !f.isOutputWriteOnly(i))) {
        res.add(o);
      }
    }
    return res;
  }
default :
throw new STCRuntimeError("String_Node_Str" + op);
}
}
Program: 132929
Project: 132929
Buggy source:
public boolean isOutputWriteOnly(int i){
  return oListWriteOnly.get(i);
}

Fixed version (ground truth):
public boolean isOutputWriteOnly(int i){
  return oListWriteOnly.contains(oList.get(i));
}
Program: 132930
Project: 132930
Buggy source:
public void makeOutputWriteOnly(int i){
  assert(i >= 0 && i < oList.size());
  assert(!Types.isFile(oList.get(i).type()));
  oListWriteOnly.set(i,true);
}

Fixed version (ground truth):
public void makeOutputWriteOnly(int i){
  assert(i >= 0 && i < oList.size());
  assert(!Types.isFile(oList.get(i).type()));
  Var output=oList.get(i);
  if (!oListWriteOnly.contains(output)) {
    oListWriteOnly.add(output);
  }
}
Program: 132931
Project: 132931
Buggy source:
public Function(String name,List<Var> iList,List<WaitVar> blockingInputs,List<Var> oList,TaskMode mode,Block mainBlock){
  if (mainBlock.getType() != BlockType.MAIN_BLOCK) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str");
  }
  this.name=name;
  this.iList=new ArrayList<Var>(iList);
  this.oList=new ArrayList<Var>(oList);
  this.oListWriteOnly=new ArrayList<Boolean>(oList.size());
  for (int i=0; i < oList.size(); i++) {
    this.oListWriteOnly.add(false);
  }
  this.mode=mode;
  this.mainBlock=mainBlock;
  this.mainBlock.setParent(this);
  this.blockingInputs=new ArrayList<WaitVar>(blockingInputs);
}

Fixed version (ground truth):
public Function(String name,List<Var> iList,List<WaitVar> blockingInputs,List<Var> oList,TaskMode mode,Block mainBlock){
  if (mainBlock.getType() != BlockType.MAIN_BLOCK) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str");
  }
  this.name=name;
  this.iList=new ArrayList<Var>(iList);
  this.oList=new ArrayList<Var>(oList);
  this.oListWriteOnly=new ArrayList<Var>();
  this.mode=mode;
  this.mainBlock=mainBlock;
  this.mainBlock.setParent(this);
  this.blockingInputs=new ArrayList<WaitVar>(blockingInputs);
}
Program: 132932
Project: 132932
Buggy source:
/** 
 * list outputs augmented with info about whether they are write-only
 * @return
 */
public List<PassedVar> getPassedOutputList(){
  ArrayList<PassedVar> res=new ArrayList<PassedVar>();
  assert(oList.size() == oListWriteOnly.size());
  for (int i=0; i < oList.size(); i++) {
    res.add(new PassedVar(oList.get(i),oListWriteOnly.get(i)));
  }
  return res;
}

Fixed version (ground truth):
/** 
 * list outputs augmented with info about whether they are write-only
 * @return
 */
public List<PassedVar> getPassedOutputList(){
  ArrayList<PassedVar> res=new ArrayList<PassedVar>();
  for (int i=0; i < oList.size(); i++) {
    Var out=oList.get(i);
    res.add(new PassedVar(out,oListWriteOnly.contains(out)));
  }
  return res;
}
Program: 132933
Project: 132933
Buggy source:
private static Arg evalStringOp(BuiltinOpcode op,List<Arg> constInputs){
  if (op == BuiltinOpcode.STRCAT) {
    StringBuilder sb=new StringBuilder();
    for (    Arg oa : constInputs) {
      sb.append(oa.getStringLit());
    }
    return Arg.createStringLit(sb.toString());
  }
 else   if (constInputs.size() == 1) {
    String arg1=constInputs.get(0).getStringLit();
switch (op) {
case COPY_STRING:
      return Arg.createStringLit(arg1);
case STRTOINT:
    try {
      long val=Long.parseLong(arg1);
      return Arg.createIntLit(val);
    }
 catch (    NumberFormatException ex) {
    }
  break;
case STRTOFLOAT:
try {
  double val=Double.valueOf(arg1);
  return Arg.createFloatLit(val);
}
 catch (NumberFormatException ex) {
}
break;
}
}
 else if (constInputs.size() == 2) {
String arg1=constInputs.get(0).getStringLit();
String arg2=constInputs.get(1).getStringLit();
switch (op) {
case EQ_STRING:
return Arg.createBoolLit(arg1.equals(arg2));
case NEQ_STRING:
return Arg.createBoolLit(!arg1.equals(arg2));
default :
break;
}
}
return null;
}

Fixed version (ground truth):
private static Arg evalStringOp(BuiltinOpcode op,List<Arg> constInputs){
  if (op == BuiltinOpcode.STRCAT) {
    StringBuilder sb=new StringBuilder();
    for (    Arg oa : constInputs) {
      sb.append(oa.getStringLit());
    }
    return Arg.createStringLit(sb.toString());
  }
 else   if (constInputs.size() == 1) {
    String arg1=constInputs.get(0).getStringLit();
switch (op) {
case COPY_STRING:
      return Arg.createStringLit(arg1);
case STRTOINT:
    try {
      long val=Long.parseLong(arg1);
      return Arg.createIntLit(val);
    }
 catch (    NumberFormatException ex) {
    }
  break;
case STRTOFLOAT:
try {
  double val=Double.valueOf(arg1);
  return Arg.createFloatLit(val);
}
 catch (NumberFormatException ex) {
}
break;
default :
}
}
 else if (constInputs.size() == 2) {
String arg1=constInputs.get(0).getStringLit();
String arg2=constInputs.get(1).getStringLit();
switch (op) {
case EQ_STRING:
return Arg.createBoolLit(arg1.equals(arg2));
case NEQ_STRING:
return Arg.createBoolLit(!arg1.equals(arg2));
default :
break;
}
}
return null;
}
Program: 132935
Project: 132935
Buggy source:
/** 
 * @return List of outputs that are piecewise assigned
 */
public List<Var> getPiecewiseAssignedOutputs(){
switch (op) {
case ARRAY_INSERT_FUTURE:
case ARRAY_INSERT_IMM:
case ARRAYREF_INSERT_FUTURE:
case ARRAYREF_INSERT_IMM:
    return getOutputs();
case ARRAY_CREATE_NESTED_FUTURE:
case ARRAY_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
case ARRAYREF_CREATE_NESTED_IMM:
{
    List<Var> outputs=getOutputs();
    return outputs.subList(1,outputs.size());
  }
case STRUCT_INSERT:
case STRUCT_CLOSE:
return getOutputs();
default :
return Var.NONE;
}
}

Fixed version (ground truth):
/** 
 * @return List of outputs that are piecewise assigned
 */
public List<Var> getPiecewiseAssignedOutputs(){
switch (op) {
case ARRAY_INSERT_FUTURE:
case ARRAY_INSERT_IMM:
case ARRAYREF_INSERT_FUTURE:
case ARRAYREF_INSERT_IMM:
    return getOutputs();
case ARRAY_CREATE_NESTED_FUTURE:
case ARRAY_CREATE_NESTED_IMM:
case ARRAYREF_CREATE_NESTED_FUTURE:
case ARRAYREF_CREATE_NESTED_IMM:
{
    List<Var> outputs=getOutputs();
    return outputs.subList(1,outputs.size());
  }
case STRUCT_INSERT:
case STRUCT_CLOSE:
return getOutputs();
case GET_OUTPUT_FILENAME:
return Collections.singletonList(getOutput(1));
default :
return Var.NONE;
}
}
Program: 132936
Project: 132936
Buggy source:
public static void fixupFunction(Logger logger,Program prog,Function fn,Set<Var> referencedGlobals,boolean updateLists){
  HierarchicalSet<Var> fnargs=new HierarchicalSet<Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.add(v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.add(v);
  }
  for (  Entry<String,Arg> e : prog.getGlobalConsts().entrySet()) {
    Arg a=e.getValue();
    Var v=new Var(a.futureType(),e.getKey(),VarStorage.GLOBAL_CONST,DefType.GLOBAL_CONST,null);
    fnargs.add(v);
  }
  Pair<Set<Var>,Set<Var>> res=fixupBlockRec(logger,fn,fn.mainBlock(),ExecContext.CONTROL,fnargs,referencedGlobals,updateLists);
  Set<Var> read=res.val1;
  Set<Var> written=res.val2;
  if (updateLists) {
    for (int i=0; i < fn.getOutputList().size(); i++) {
      Var output=fn.getOutput(i);
      if (!read.contains(output)) {
        fn.makeOutputWriteOnly(i);
      }
    }
  }
  read.removeAll(fn.getInputList());
  read.removeAll(fn.getOutputList());
  if (read.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ read.toString());
  }
  written.removeAll(fn.getOutputList());
  for (  Var v : fn.getInputList()) {
    if (Types.isScalarUpdateable(v.type())) {
      written.remove(v);
    }
  }
  if (written.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ written.toString());
  }
}

Fixed version (ground truth):
public static void fixupFunction(Logger logger,Program prog,Function fn,Set<Var> referencedGlobals,boolean updateLists){
  HierarchicalSet<Var> fnargs=new HierarchicalSet<Var>();
  for (  Var v : fn.getInputList()) {
    fnargs.add(v);
  }
  for (  Var v : fn.getOutputList()) {
    fnargs.add(v);
  }
  for (  Entry<String,Arg> e : prog.getGlobalConsts().entrySet()) {
    Arg a=e.getValue();
    Var v=new Var(a.futureType(),e.getKey(),VarStorage.GLOBAL_CONST,DefType.GLOBAL_CONST,null);
    fnargs.add(v);
  }
  Pair<Set<Var>,Set<Var>> res=fixupBlockRec(logger,fn,fn.mainBlock(),ExecContext.CONTROL,fnargs,referencedGlobals,updateLists);
  Set<Var> read=res.val1;
  Set<Var> written=res.val2;
  if (updateLists) {
    for (int i=0; i < fn.getOutputList().size(); i++) {
      Var output=fn.getOutput(i);
      if (!read.contains(output) && !Types.hasReadableSideChannel(output.type())) {
        fn.makeOutputWriteOnly(i);
      }
    }
  }
  read.removeAll(fn.getInputList());
  read.removeAll(fn.getOutputList());
  if (read.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ read.toString());
  }
  written.removeAll(fn.getOutputList());
  for (  Var v : fn.getInputList()) {
    if (Types.isScalarUpdateable(v.type())) {
      written.remove(v);
    }
  }
  if (written.size() > 0) {
    throw new STCRuntimeError("String_Node_Str" + fn.getName() + "String_Node_Str"+ written.toString());
  }
}
Program: 132937
Project: 132937
Buggy source:
public void makeOutputWriteOnly(int i){
  oListWriteOnly.set(i,true);
}

Fixed version (ground truth):
public void makeOutputWriteOnly(int i){
  assert(i >= 0 && i < oList.size());
  assert(!Types.isFile(oList.get(i).type()));
  oListWriteOnly.set(i,true);
}
Program: 132938
Project: 132938
Buggy source:
/** 
 * Called when we enter a construct that blocked on v
 * @param var
 */
public void close(Var var,boolean recursive){
  Stack<Var> work=new Stack<Var>();
  work.add(var);
  while (!work.empty()) {
    Var v=work.pop();
    closed.add(v);
    CopyOnWriteSmallSet<Var> deps=dependsOn.remove(v);
    if (deps != null) {
      work.addAll(deps);
    }
  }
  if (recursive) {
    recursivelyClosed.add(var);
  }
}

Fixed version (ground truth):
/** 
 * Called when we enter a construct that blocked on v
 * @param var
 */
public void close(Var var,boolean recursive){
}
Program: 132940
Project: 132940
Buggy source:
/** 
 * @param res
 * @param replace for debugging purposes, set to true if we intend to replace
 */
public void addComputedValue(ResultVal res,boolean replace){
  boolean outClosed=res.outClosed();
  if (isAvailable(res.value())) {
    if (!replace) {
      throw new STCRuntimeError("String_Node_Str" + getLocation(res.value()) + "String_Node_Str"+ res);
    }
  }
 else   if (replace) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + res + "String_Node_Str");
  }
  Arg valLoc=res.location();
  availableVals.put(res.value(),valLoc);
  if (valLoc.isVar()) {
    varContents.put(valLoc.getVar(),res.value());
    if (outClosed) {
      close(valLoc.getVar(),false);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param res
 * @param replace for debugging purposes, set to true if we intend to replace
 */
public void addComputedValue(ResultVal res,boolean replace){
  boolean outClosed=res.outClosed();
  if (isAvailable(res.value())) {
    if (!replace) {
      throw new STCRuntimeError("String_Node_Str" + getLocation(res.value()) + "String_Node_Str"+ res);
    }
  }
 else   if (replace) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + res + "String_Node_Str");
  }
  Arg valLoc=res.location();
  availableVals.put(res.value(),valLoc);
  if (valLoc.isVar()) {
    varContents.put(valLoc.getVar(),res.value());
    if (outClosed) {
      if (logger.isTraceEnabled()) {
        logger.trace("String_Node_Str" + valLoc + "String_Node_Str");
      }
      close(valLoc.getVar(),false);
    }
  }
}
Program: 132942
Project: 132942
Buggy source:
public ForwardDataflow(boolean keepExplicitWaits){
  this.keepExplicitWaits=keepExplicitWaits;
}

Fixed version (ground truth):
public ForwardDataflow(boolean reorderingAllowed){
  this.reorderingAllowed=reorderingAllowed;
}
Program: 132943
Project: 132943
Buggy source:
private static void handleInstruction(Logger logger,Function f,ExecContext execCx,Block block,ListIterator<Statement> stmts,Instruction inst,State cv,HierarchicalMap<Var,Arg> replaceInputs,HierarchicalMap<Var,Arg> replaceAll){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + replaceInputs);
    logger.trace("String_Node_Str" + replaceAll);
    logger.trace("String_Node_Str" + cv.availableVals);
    State ancestor=cv.parent;
    int up=1;
    while (ancestor != null) {
      logger.trace("String_Node_Str" + up + "String_Node_Str"+ ancestor.availableVals);
      up++;
      ancestor=ancestor.parent;
    }
    logger.trace("String_Node_Str" + cv.closed);
    logger.trace("String_Node_Str");
    logger.trace("String_Node_Str" + inst);
  }
  inst.renameVars(replaceInputs,RenameMode.VALUE);
  inst.renameVars(replaceAll,RenameMode.REFERENCE);
  List<ResultVal> icvs=inst.getResults(cv);
  updateReplacements(logger,f,inst,cv,icvs,replaceInputs,replaceAll);
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + inst);
  }
  if (switchToImmediate(logger,f,execCx,block,cv,inst,stmts)) {
    return;
  }
  List<Var> in=inst.getBlockingInputs();
  if (in != null) {
    for (    Var ov : inst.getOutputs()) {
      if (!Types.isScalarValue(ov.type())) {
        cv.setDependencies(ov,in);
      }
    }
  }
  for (  Var out : inst.getClosedOutputs()) {
    cv.close(out,false);
  }
}

Fixed version (ground truth):
private void handleInstruction(Logger logger,Function f,ExecContext execCx,Block block,ListIterator<Statement> stmts,Instruction inst,State cv,HierarchicalMap<Var,Arg> replaceInputs,HierarchicalMap<Var,Arg> replaceAll){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + replaceInputs);
    logger.trace("String_Node_Str" + replaceAll);
    logger.trace("String_Node_Str" + cv.availableVals);
    State ancestor=cv.parent;
    int up=1;
    while (ancestor != null) {
      logger.trace("String_Node_Str" + up + "String_Node_Str"+ ancestor.availableVals);
      up++;
      ancestor=ancestor.parent;
    }
    logger.trace("String_Node_Str" + cv.closed);
    logger.trace("String_Node_Str");
    logger.trace("String_Node_Str" + inst);
  }
  inst.renameVars(replaceInputs,RenameMode.VALUE);
  inst.renameVars(replaceAll,RenameMode.REFERENCE);
  List<ResultVal> icvs=inst.getResults(cv);
  updateReplacements(logger,f,inst,cv,icvs,replaceInputs,replaceAll);
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + inst);
  }
  if (switchToImmediate(logger,f,execCx,block,cv,inst,stmts)) {
    return;
  }
  if (!reorderingAllowed) {
    List<Var> in=inst.getBlockingInputs();
    if (in != null) {
      for (      Var ov : inst.getOutputs()) {
        if (!Types.isScalarValue(ov.type())) {
          cv.setDependencies(ov,in);
        }
      }
    }
  }
  for (  Var out : inst.getClosedOutputs()) {
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + out.name() + "String_Node_Str");
    }
    cv.close(out,false);
  }
}
Program: 132944
Project: 132944
Buggy source:
public HoistTracking makeChild(Block childBlock,int maxHoist,int maxLoopHoist){
  return new HoistTracking(this,childBlock,maxHoist,maxLoopHoist,writeMap.makeChildMap(),piecewiseWriteMap.makeChildMap(),declareMap.makeChildMap(),initializedMap.makeChildMap());
}

Fixed version (ground truth):
public HoistTracking makeChild(Block childBlock,ExecContext newExecCx,int maxHoist,int maxLoopHoist){
  return new HoistTracking(this,childBlock,execCx,maxHoist,maxLoopHoist,writeMap.makeChildMap(),piecewiseWriteMap.makeChildMap(),declareMap.makeChildMap(),initializedMap.makeChildMap());
}
Program: 132945
Project: 132945
Buggy source:
@Override public void optimize(Logger logger,Program prog){
  for (  Function f : prog.getFunctions()) {
    HoistTracking global=new HoistTracking();
    for (    Var gv : prog.getGlobalVars()) {
      global.write(gv,false);
      global.declare(gv);
    }
    HoistTracking mainBlockState=global.makeChild(f.mainBlock(),0,0);
    for (    Var in : f.getInputList()) {
      mainBlockState.write(in,false);
      mainBlockState.declare(in);
    }
    for (    Var out : f.getOutputList()) {
      mainBlockState.declare(out);
    }
    hoistRec(logger,mainBlockState);
  }
}

Fixed version (ground truth):
@Override public void optimize(Logger logger,Program prog){
  for (  Function f : prog.getFunctions()) {
    HoistTracking global=new HoistTracking();
    for (    Var gv : prog.getGlobalVars()) {
      global.write(gv,false);
      global.declare(gv);
    }
    HoistTracking mainBlockState=global.makeChild(f.mainBlock(),ExecContext.CONTROL,0,0);
    for (    Var in : f.getInputList()) {
      mainBlockState.write(in,false);
      mainBlockState.declare(in);
    }
    for (    Var out : f.getOutputList()) {
      mainBlockState.declare(out);
    }
    hoistRec(logger,mainBlockState);
  }
}
Program: 132946
Project: 132946
Buggy source:
private HoistTracking(HoistTracking parent,Block block,int maxHoist,int maxLoopHoist,HierarchicalMap<Var,Block> writeMap,HierarchicalMap<Var,Block> piecewiseWriteMap,HierarchicalMap<Var,Block> declareMap,HierarchicalMap<Var,Block> initializedMap){
  super();
  this.parent=parent;
  this.block=block;
  this.maxHoist=maxHoist;
  this.maxLoopHoist=maxLoopHoist;
  this.writeMap=writeMap;
  this.piecewiseWriteMap=piecewiseWriteMap;
  this.declareMap=declareMap;
  this.initializedMap=initializedMap;
}

Fixed version (ground truth):
private HoistTracking(HoistTracking parent,Block block,ExecContext execCx,int maxHoist,int maxLoopHoist,HierarchicalMap<Var,Block> writeMap,HierarchicalMap<Var,Block> piecewiseWriteMap,HierarchicalMap<Var,Block> declareMap,HierarchicalMap<Var,Block> initializedMap){
  super();
  this.parent=parent;
  this.block=block;
  this.execCx=execCx;
  this.maxHoist=maxHoist;
  this.maxLoopHoist=maxLoopHoist;
  this.writeMap=writeMap;
  this.piecewiseWriteMap=piecewiseWriteMap;
  this.declareMap=declareMap;
  this.initializedMap=initializedMap;
}
Program: 132947
Project: 132947
Buggy source:
private RuleProps buildRuleProps(TaskProps props){
  Expression priority=TclUtil.argToExpr(props.get(TaskPropKey.PRIORITY),true);
  TclTarget target=TclTarget.fromArg(props.get(TaskPropKey.PRIORITY));
  Expression parallelism=TclUtil.argToExpr(props.get(TaskPropKey.PARALLELISM),true);
  RuleProps ruleProps=new RuleProps(target,parallelism,priority);
  return ruleProps;
}

Fixed version (ground truth):
private RuleProps buildRuleProps(TaskProps props){
  Expression priority=TclUtil.argToExpr(props.get(TaskPropKey.PRIORITY),true);
  TclTarget target=TclTarget.fromArg(props.get(TaskPropKey.TARGET));
  Expression parallelism=TclUtil.argToExpr(props.get(TaskPropKey.PARALLELISM),true);
  RuleProps ruleProps=new RuleProps(target,parallelism,priority);
  return ruleProps;
}
Program: 132948
Project: 132948
Buggy source:
@Override public Block branchPredict(Map<Var,Arg> knownConstants){
  if (switchVar.isVar() && knownConstants.containsKey(switchVar.getVar())) {
    this.switchVar=knownConstants.get(switchVar.getVar());
  }
  long val=switchVar.getIntLit();
  for (int i=0; i < caseLabels.size(); i++) {
    if (val == caseLabels.get(i)) {
      return caseBlocks.get(i);
    }
  }
  return defaultBlock;
}

Fixed version (ground truth):
@Override public Block branchPredict(Map<Var,Arg> knownConstants){
  if (switchVar.isVar()) {
    if (knownConstants.containsKey(switchVar.getVar())) {
      this.switchVar=knownConstants.get(switchVar.getVar());
    }
 else {
      return null;
    }
  }
  long val=switchVar.getIntLit();
  for (int i=0; i < caseLabels.size(); i++) {
    if (val == caseLabels.get(i)) {
      return caseBlocks.get(i);
    }
  }
  return defaultBlock;
}
Program: 132949
Project: 132949
Buggy source:
@Override public void appendTo(StringBuilder sb,ExprContext mode){
  assert(mode != ExprContext.VALUE_STRING);
  if (parenthesise)   sb.append("String_Node_Str");
  boolean first=true;
  for (  Expression e : exprs) {
    if (first) {
      first=false;
    }
 else {
      sb.append("String_Node_Str");
    }
    e.appendTo(sb,mode);
  }
  if (parenthesise)   sb.append("String_Node_Str");
}

Fixed version (ground truth):
@Override public void appendTo(StringBuilder sb,ExprContext mode){
  if (parenthesise)   sb.append("String_Node_Str");
  boolean first=true;
  for (  Expression e : exprs) {
    if (first) {
      first=false;
    }
 else {
      sb.append("String_Node_Str");
    }
    e.appendTo(sb,mode);
  }
  if (parenthesise)   sb.append("String_Node_Str");
}
Program: 132950
Project: 132950
Buggy source:
/** 
 * Generate code for a rule
 * @param symbol
 * @param inputs
 * @param action the action, using a tcl list to ensure proper escaping
 * @param type
 * @return
 */
private static Sequence ruleHelper(String symbol,List<? extends Expression> inputs,Expression action,TaskMode type,Target target,Expression priority,ExecContext execCx){
  Sequence res=new Sequence();
  if (inputs.isEmpty()) {
    if (type != TaskMode.LOCAL && type != TaskMode.LOCAL_CONTROL) {
      res.add(spawnTask(action,type,target,priority,execCx));
      return res;
    }
  }
  if (priority != null)   res.add(setPriority(priority));
  Token ruleCmd=execCx == ExecContext.CONTROL ? RULE : SPAWN_RULE;
  res.add(new Command(ruleCmd,new Token(symbol),new TclList(inputs),tclRuleType(type),target.toTcl(),action));
  if (priority != null)   res.add(resetPriority());
  return res;
}

Fixed version (ground truth):
/** 
 * Generate code for a rule
 * @param symbol
 * @param inputs
 * @param action tokens making up the action
 * @param type
 * @return
 */
private static Sequence ruleHelper(String symbol,List<? extends Expression> inputs,List<Expression> action,TaskMode type,Target target,Expression priority,ExecContext execCx){
  if (inputs.isEmpty()) {
    if (type != TaskMode.LOCAL && type != TaskMode.LOCAL_CONTROL) {
      return spawnTask(action,type,target,priority,execCx);
    }
  }
  Sequence res=new Sequence();
  if (priority != null)   res.add(setPriority(priority));
  Token ruleCmd=execCx == ExecContext.CONTROL ? RULE : SPAWN_RULE;
  res.add(new Command(ruleCmd,new Token(symbol),new TclList(inputs),tclRuleType(type),target.toTcl(),TclUtil.tclStringAsList(action)));
  if (priority != null)   res.add(resetPriority());
  return res;
}
Program: 132951
Project: 132951
Buggy source:
/** 
 * @param symbol
 * @param blockOn
 * @param action
 * @param mode
 * @return
 */
public static Sequence rule(String symbol,List<? extends Expression> blockOn,Expression action,TaskMode mode,Target target,Expression priority,ExecContext execCx){
  return ruleHelper(symbol,blockOn,action,mode,target,priority,execCx);
}

Fixed version (ground truth):
/** 
 * @param symbol
 * @param blockOn
 * @param action
 * @param mode
 * @return
 */
public static Sequence rule(String symbol,List<? extends Expression> blockOn,List<Expression> action,TaskMode mode,Target target,Expression priority,ExecContext execCx){
  return ruleHelper(symbol,blockOn,action,mode,target,priority,execCx);
}
Program: 132952
Project: 132952
Buggy source:
public static Sequence loopRule(String symbol,List<Value> args,List<? extends Expression> blockOn,ExecContext execCx){
  assert(execCx == ExecContext.CONTROL);
  List<Expression> actionElems=new ArrayList<Expression>();
  actionElems.add(new Token(symbol));
  for (  Value arg : args) {
    actionElems.add(arg);
  }
  TclList action=new TclList(actionElems);
  return ruleHelper(symbol,blockOn,action,TaskMode.CONTROL,Target.rankAny(),null,execCx);
}

Fixed version (ground truth):
public static Sequence loopRule(String symbol,List<Value> args,List<? extends Expression> blockOn,ExecContext execCx){
  assert(execCx == ExecContext.CONTROL);
  List<Expression> action=new ArrayList<Expression>();
  action.add(new Token(symbol));
  for (  Value arg : args) {
    action.add(arg);
  }
  return ruleHelper(symbol,blockOn,action,TaskMode.CONTROL,Target.rankAny(),null,execCx);
}
Program: 132953
Project: 132953
Buggy source:
private static Command spawnTask(Expression action,TaskMode type,Target target,Expression priority,ExecContext execCx){
  Token ADLB_PUT=new Token("String_Node_Str");
  LiteralInt TURBINE_NULL_RULE=new LiteralInt(-1);
  if (priority == null) {
    priority=currentPriority();
  }
  assert(type == TaskMode.CONTROL || type == TaskMode.WORKER);
  return new Command(ADLB_PUT,target.toTcl(),adlbWorkType(type),new TclString(Arrays.asList(TURBINE_NULL_RULE,action)),priority);
}

Fixed version (ground truth):
private static Sequence spawnTask(List<Expression> action,TaskMode type,Target target,Expression priority,ExecContext execCx){
  Sequence res=new Sequence();
  Token ADLB_PUT=new Token("String_Node_Str");
  LiteralInt TURBINE_NULL_RULE=new LiteralInt(-1);
  if (priority == null) {
    priority=currentPriority();
  }
  Value priorityVar=new Value(TCLTMP_PRIO);
  res.add(new SetVariable(TCLTMP_PRIO,priority));
  List<Expression> taskTokens=new ArrayList<Expression>();
  if (type == TaskMode.WORKER) {
    taskTokens.add(TURBINE_NULL_RULE);
    taskTokens.addAll(action);
  }
 else {
    assert(type == TaskMode.CONTROL);
    taskTokens.add(new Token("String_Node_Str"));
    taskTokens.add(new Token("String_Node_Str"));
    taskTokens.add(priorityVar);
    taskTokens.addAll(action);
  }
  res.add(new Command(ADLB_PUT,target.toTcl(),adlbWorkType(type),TclUtil.tclStringAsList(taskTokens),priorityVar));
  return res;
}
Program: 132954
Project: 132954
Buggy source:
public static Sequence deepRule(String symbol,List<? extends Expression> inputs,int[] depths,boolean[] isFile,Expression action,TaskMode mode,Expression priority,ExecContext execCx){
  assert(inputs.size() == depths.length);
  assert(inputs.size() == isFile.length);
  List<Expression> depthExprs=new ArrayList<Expression>(depths.length);
  List<Expression> isFileExprs=new ArrayList<Expression>(isFile.length);
  for (  int depth : depths) {
    depthExprs.add(new LiteralInt(depth));
  }
  for (  boolean b : isFile) {
    isFileExprs.add(LiteralInt.boolValue(b));
  }
  Sequence res=new Sequence();
  if (priority != null)   res.add(setPriority(priority));
  res.add(new Command(DEEPRULE,new Token(symbol),new TclList(inputs),new TclList(depthExprs),new TclList(isFileExprs),tclRuleType(mode),action));
  if (priority != null)   res.add(resetPriority());
  return res;
}

Fixed version (ground truth):
public static Sequence deepRule(String symbol,List<? extends Expression> inputs,int[] depths,boolean[] isFile,List<Expression> action,TaskMode mode,Expression priority,ExecContext execCx){
  assert(inputs.size() == depths.length);
  assert(inputs.size() == isFile.length);
  List<Expression> depthExprs=new ArrayList<Expression>(depths.length);
  List<Expression> isFileExprs=new ArrayList<Expression>(isFile.length);
  for (  int depth : depths) {
    depthExprs.add(new LiteralInt(depth));
  }
  for (  boolean b : isFile) {
    isFileExprs.add(LiteralInt.boolValue(b));
  }
  Sequence res=new Sequence();
  if (priority != null)   res.add(setPriority(priority));
  res.add(new Command(DEEPRULE,new Token(symbol),new TclList(inputs),new TclList(depthExprs),new TclList(isFileExprs),tclRuleType(mode),TclUtil.tclStringAsList(action)));
  if (priority != null)   res.add(resetPriority());
  return res;
}
Program: 132955
Project: 132955
Buggy source:
private Expression buildActionFromVars(String procName,List<Var> usedVariables){
  List<Expression> exprs=new ArrayList<Expression>();
  for (  Var v : usedVariables) {
    Type t=v.type();
    if (Types.isScalarFuture(t) || Types.isRef(t) || Types.isArray(t)|| Types.isStruct(t)|| Types.isScalarUpdateable(t)) {
      exprs.add(varToExpr(v));
    }
 else     if (Types.isScalarValue(t)) {
      PrimType pt=t.primType();
      if (pt == PrimType.INT || pt == PrimType.BOOL || pt == PrimType.FLOAT || pt == PrimType.STRING) {
        exprs.add(varToExpr(v));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + v);
      }
    }
 else {
      throw new STCRuntimeError("String_Node_Str" + v);
    }
  }
  return buildAction(procName,exprs);
}

Fixed version (ground truth):
private List<Expression> buildActionFromVars(String procName,List<Var> usedVariables){
  List<Expression> exprs=new ArrayList<Expression>();
  for (  Var v : usedVariables) {
    Type t=v.type();
    if (Types.isScalarFuture(t) || Types.isRef(t) || Types.isArray(t)|| Types.isStruct(t)|| Types.isScalarUpdateable(t)) {
      exprs.add(varToExpr(v));
    }
 else     if (Types.isScalarValue(t)) {
      PrimType pt=t.primType();
      if (pt == PrimType.INT || pt == PrimType.BOOL || pt == PrimType.FLOAT || pt == PrimType.STRING) {
        exprs.add(varToExpr(v));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + v);
      }
    }
 else {
      throw new STCRuntimeError("String_Node_Str" + v);
    }
  }
  return buildAction(procName,exprs);
}
Program: 132958
Project: 132958
Buggy source:
private Expression buildAction(String procName,List<Expression> args){
  ArrayList<Expression> ruleTokens=new ArrayList<Expression>();
  ruleTokens.add(new Token(procName));
  ruleTokens.add(new Value(Turbine.LOCAL_STACK_NAME));
  ruleTokens.addAll(args);
  return TclUtil.tclStringAsList(ruleTokens);
}

Fixed version (ground truth):
private List<Expression> buildAction(String procName,List<Expression> args){
  ArrayList<Expression> ruleTokens=new ArrayList<Expression>();
  ruleTokens.add(new Token(procName));
  ruleTokens.add(new Value(Turbine.LOCAL_STACK_NAME));
  ruleTokens.addAll(args);
  return ruleTokens;
}
Program: 132960
Project: 132960
Buggy source:
private boolean rearrangeWaitsRec(Logger logger,Function fn,Block block,ExecContext currContext){
  List<WaitStatement> toInline=new ArrayList<WaitStatement>();
  boolean changed=false;
  for (  Continuation c : block.getContinuations()) {
    ExecContext newContext=c.childContext(currContext);
    for (    Block childB : c.getBlocks()) {
      if (rearrangeWaitsRec(logger,fn,childB,newContext)) {
        changed=true;
      }
    }
    if (c.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement wait=(WaitStatement)c;
      if (tryReduce(logger,fn,currContext,newContext,wait)) {
        toInline.add(wait);
      }
 else       if (squashWaits(logger,fn,wait,newContext)) {
        changed=true;
      }
    }
  }
  for (  WaitStatement w : toInline) {
    w.inlineInto(block);
    changed=true;
  }
  return changed;
}

Fixed version (ground truth):
private boolean rearrangeWaitsRec(Logger logger,Function fn,Block block,ExecContext currContext){
  List<WaitStatement> toInline=new ArrayList<WaitStatement>();
  boolean changed=false;
  for (  Continuation c : block.getContinuations()) {
    ExecContext newContext=c.childContext(currContext);
    for (    Block childB : c.getBlocks()) {
      if (rearrangeWaits(logger,fn,childB,newContext)) {
        changed=true;
      }
    }
    if (c.getType() == ContinuationType.WAIT_STATEMENT) {
      WaitStatement wait=(WaitStatement)c;
      if (tryReduce(logger,fn,currContext,newContext,wait)) {
        toInline.add(wait);
      }
 else       if (squashWaits(logger,fn,wait,newContext)) {
        changed=true;
      }
    }
  }
  for (  WaitStatement w : toInline) {
    w.inlineInto(block);
    changed=true;
  }
  return changed;
}