Program: 133261
Project: 133261
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<Variable> oList,Map<String,String> renames) throws UserException {
  assert(tree.getChildCount() >= 2 && tree.getChildCount() <= 3);
  String f=tree.child(0).getText();
  try {
    if (Builtins.isAssertVariant(f) && Settings.getBoolean(Settings.OPT_DISABLE_ASSERTS)) {
      return;
    }
  }
 catch (  InvalidOptionException e) {
    throw new STCRuntimeError("String_Node_Str" + e.toString());
  }
  SwiftAST arglist=tree.child(1);
  FunctionType ftype=context.lookupFunction(f);
  if (ftype == null) {
    throw UndefinedFunctionException.unknownFunction(context,f);
  }
  ArrayList<Variable> argVars=new ArrayList<Variable>(arglist.getChildCount());
  int argcount=arglist.getChildCount();
  for (int i=0; i < argcount; i++) {
    SwiftAST argtree=arglist.child(i);
    InArgT expType=ftype.getInputs().get(Math.min(i,ftype.getInputs().size() - 1));
    SwiftType argtype;
    if (expType.getAltCount() == 1) {
      argtype=TypeChecker.findSingleExprType(context,argtree,expType.getAlt(0));
    }
 else {
      argtype=TypeChecker.findSingleExprType(context,argtree);
      SwiftType matching=TypeChecker.whichAlternativeType(expType,argtype);
      if (matching != null && Types.isUpdateableEquiv(argtype,matching)) {
        argtree.clearTypeInfo();
        argtype=TypeChecker.findSingleExprType(context,argtree,matching);
      }
    }
    argVars.add(evalExprToTmp(context,argtree,argtype,false,renames));
  }
  Variable priorityVal=null;
  boolean openedWait=false;
  List<Variable> waitContainers=null;
  Context callContext=context;
  if (tree.getChildCount() == 3) {
    SwiftAST priorityT=tree.child(2);
    Variable priorityFuture=evalExprToTmp(context,priorityT,Types.FUTURE_INTEGER,false,renames);
    waitContainers=new ArrayList<Variable>(0);
    ArrayList<Variable> usedVariables=new ArrayList<Variable>();
    usedVariables.addAll(argVars);
    usedVariables.addAll(oList);
    backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(priorityFuture),usedVariables,waitContainers,false);
    openedWait=true;
    callContext=new LocalContext(context);
    priorityVal=varCreator.fetchValueOf(callContext,priorityFuture);
  }
  callFunction(context,f,oList,argVars,priorityVal);
  if (openedWait) {
    backend.endWaitStatement(waitContainers);
  }
}

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<Variable> oList,Map<String,String> renames) throws UserException {
  assert(tree.getChildCount() >= 2 && tree.getChildCount() <= 3);
  String f=tree.child(0).getText();
  try {
    if (Builtins.isAssertVariant(f) && Settings.getBoolean(Settings.OPT_DISABLE_ASSERTS)) {
      return;
    }
  }
 catch (  InvalidOptionException e) {
    throw new STCRuntimeError("String_Node_Str" + e.toString());
  }
  SwiftAST arglist=tree.child(1);
  FunctionType ftype=context.lookupFunction(f);
  if (ftype == null) {
    throw UndefinedFunctionException.unknownFunction(context,f);
  }
  if (arglist.getChildCount() > 0 && ftype.getInputs().size() == 0) {
    throw new TypeMismatchException(context,"String_Node_Str" + "String_Node_Str" + f);
  }
  ArrayList<Variable> argVars=new ArrayList<Variable>(arglist.getChildCount());
  int argcount=arglist.getChildCount();
  for (int i=0; i < argcount; i++) {
    SwiftAST argtree=arglist.child(i);
    InArgT expType=ftype.getInputs().get(Math.min(i,ftype.getInputs().size() - 1));
    SwiftType argtype;
    if (expType.getAltCount() == 1) {
      argtype=TypeChecker.findSingleExprType(context,argtree,expType.getAlt(0));
    }
 else {
      argtype=TypeChecker.findSingleExprType(context,argtree);
      SwiftType matching=TypeChecker.whichAlternativeType(expType,argtype);
      if (matching != null && Types.isUpdateableEquiv(argtype,matching)) {
        argtree.clearTypeInfo();
        argtype=TypeChecker.findSingleExprType(context,argtree,matching);
      }
    }
    argVars.add(evalExprToTmp(context,argtree,argtype,false,renames));
  }
  Variable priorityVal=null;
  boolean openedWait=false;
  List<Variable> waitContainers=null;
  Context callContext=context;
  if (tree.getChildCount() == 3) {
    SwiftAST priorityT=tree.child(2);
    Variable priorityFuture=evalExprToTmp(context,priorityT,Types.FUTURE_INTEGER,false,renames);
    waitContainers=new ArrayList<Variable>(0);
    ArrayList<Variable> usedVariables=new ArrayList<Variable>();
    usedVariables.addAll(argVars);
    usedVariables.addAll(oList);
    backend.startWaitStatement(context.getFunctionContext().constructName("String_Node_Str"),Arrays.asList(priorityFuture),usedVariables,waitContainers,false);
    openedWait=true;
    callContext=new LocalContext(context);
    priorityVal=varCreator.fetchValueOf(callContext,priorityFuture);
  }
  callFunction(context,f,oList,argVars,priorityVal);
  if (openedWait) {
    backend.endWaitStatement(waitContainers);
  }
}