nus-yam/ex-repair huggingface dataset:
Program: 132611
Project: 132611
Buggy source:
/** 
 * Check that union args are handled correctly when resolving overloads
 * @throws TypeMismatchException
 */
@Test public void testSelectOverloadUnion1() throws TypeMismatchException {
  FunctionType intFn=makeSimpleFT(Types.F_INT);
  FunctionType floatFn=makeSimpleFT(Types.F_FLOAT);
  FnID intFnID=new FnID("String_Node_Str","String_Node_Str");
  FnID floatFnID=new FnID("String_Node_Str","String_Node_Str");
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_STRING),Arrays.asList(Pair.create(intFnID,intFn),Pair.create(floatFnID,floatFn)));
  List<FnMatch> matches=concretiseInputsOverloaded(FAKE_CONTEXT,fc,true);
  assert(matches.size() == 0);
  FnMatch match=matches.get(0);
  assert(match.id.equals(intFnID));
  assert(match.concreteAlts.size() == 1);
  assert(match.concreteAlts.get(0).equals(intFn));
}

Fixed version (ground truth):
/** 
 * Check that union args are handled correctly when resolving overloads
 * @throws TypeMismatchException
 */
@Test public void testSelectOverloadUnion1() throws TypeMismatchException {
  FunctionType intFn=makeSimpleFT(Types.F_INT);
  FunctionType floatFn=makeSimpleFT(Types.F_FLOAT);
  FnID intFnID=new FnID("String_Node_Str","String_Node_Str");
  FnID floatFnID=new FnID("String_Node_Str","String_Node_Str");
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(INT_OR_STRING),Arrays.asList(Pair.create(intFnID,intFn),Pair.create(floatFnID,floatFn)));
  List<FnMatch> matches=concretiseInputsOverloaded(FAKE_CONTEXT,fc,true);
  assertEquals(1,matches.size());
  FnMatch match=matches.get(0);
  assertEquals(intFnID,match.id);
  assertEquals(1,match.concreteAlts.size());
  assertEquals(intFn,match.concreteAlts.get(0));
}
Program: 132613
Project: 132613
Buggy source:
/** 
 * Simple overload resolution test
 * @throws TypeMismatchException
 */
@Test public void testSelectOverload() throws TypeMismatchException {
  FunctionType intFn=makeSimpleFT(Types.F_INT);
  FunctionType stringFn=makeSimpleFT(Types.F_STRING);
  FnID intFnID=new FnID("String_Node_Str","String_Node_Str");
  FnID stringFnID=new FnID("String_Node_Str","String_Node_Str");
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(Types.F_STRING),Arrays.asList(Pair.create(intFnID,intFn),Pair.create(stringFnID,stringFn)));
  List<FnMatch> matches=concretiseInputsOverloaded(FAKE_CONTEXT,fc,true);
  assert(matches.size() == 0);
  FnMatch match=matches.get(0);
  assert(match.id.equals(stringFnID));
  assert(match.concreteAlts.size() == 1);
  assert(match.concreteAlts.get(0).equals(stringFn));
}

Fixed version (ground truth):
/** 
 * Simple overload resolution test
 * @throws TypeMismatchException
 */
@Test public void testSelectOverload() throws TypeMismatchException {
  FunctionType intFn=makeSimpleFT(Types.F_INT);
  FunctionType stringFn=makeSimpleFT(Types.F_STRING);
  FnID intFnID=new FnID("String_Node_Str","String_Node_Str");
  FnID stringFnID=new FnID("String_Node_Str","String_Node_Str");
  FnCallInfo fc=makeOverloadedFnCallInfo(Arrays.asList(Types.F_STRING),Arrays.asList(Pair.create(intFnID,intFn),Pair.create(stringFnID,stringFn)));
  List<FnMatch> matches=concretiseInputsOverloaded(FAKE_CONTEXT,fc,true);
  assertEquals(1,matches.size());
  FnMatch match=matches.get(0);
  assertEquals(stringFnID,match.id);
  assertEquals(1,match.concreteAlts.size());
  assertEquals(stringFn,match.concreteAlts.get(0));
}
Program: 132617
Project: 132617
Buggy source:
/** 
 * Switch to passing values directly. Do this before function inlining since function inlining will clean it up.
 * @param logger
 * @param program
 */
@Override public void optimize(Logger logger,Program program){
  Set<FnID> usedFunctionNames=program.getFunctionIDs();
  Map<FnID,Function> toInline=new HashMap<FnID,Function>();
  ListIterator<Function> fnIt=program.functionIterator();
  while (fnIt.hasNext()) {
    Function fn=fnIt.next();
    Function newFn=switchToValuePassing(logger,program.foreignFunctions(),fn,usedFunctionNames);
    if (newFn != null) {
      fnIt.remove();
      fnIt.add(newFn);
      usedFunctionNames.add(newFn.id());
      toInline.put(fn.id(),fn);
    }
  }
  FunctionInline.inlineAllOccurrences(logger,program,toInline);
}

Fixed version (ground truth):
/** 
 * Switch to passing values directly. Do this before function inlining since function inlining will clean it up.
 * @param logger
 * @param program
 */
@Override public void optimize(Logger logger,Program program){
  Set<FnID> usedFnIDs=new HashSet<FnID>(program.getFunctionMap().keySet());
  Map<FnID,Function> toInline=new HashMap<FnID,Function>();
  ListIterator<Function> fnIt=program.functionIterator();
  while (fnIt.hasNext()) {
    Function fn=fnIt.next();
    Function newFn=switchToValuePassing(logger,program.foreignFunctions(),fn,usedFnIDs);
    if (newFn != null) {
      fnIt.remove();
      fnIt.add(newFn);
      usedFnIDs.add(newFn.id());
      toInline.put(fn.id(),fn);
    }
  }
  FunctionInline.inlineAllOccurrences(logger,program,toInline);
}
Program: 132620
Project: 132620
Buggy source:
public void addUnifiedValues(GlobalConstants consts,String errContext,int stmtIndex,UnifiedValues unified) throws OptUnsafeError {
  int closedIndex=stmtIndex + 1;
  for (  Var closed : unified.closed) {
    markClosed(closed,closedIndex,false);
  }
  for (  Var closed : unified.recursivelyClosed) {
    markClosed(closed,closedIndex,true);
  }
  update(consts,errContext,unified.availableVals,null,stmtIndex);
}

Fixed version (ground truth):
public void addUnifiedValues(GlobalConstants consts,String errContext,int stmtIndex,UnifiedValues unified) throws OptUnsafeError {
  for (  Var closed : unified.closed) {
    markClosed(closed,stmtIndex,false);
  }
  for (  Var closed : unified.recursivelyClosed) {
    markClosed(closed,stmtIndex,true);
  }
  update(consts,errContext,unified.availableVals,null,stmtIndex);
}
Program: 132621
Project: 132621
Buggy source:
public void addUnifiedValues(GlobalConstants consts,String errContext,int stmtIndex,UnifiedValues unified) throws OptUnsafeError {
  for (  Var closed : unified.closed) {
    markClosed(closed,stmtIndex,false);
  }
  for (  Var closed : unified.recursivelyClosed) {
    markClosed(closed,stmtIndex,true);
  }
  update(consts,errContext,unified.availableVals,null,stmtIndex);
}

Fixed version (ground truth):
public void addUnifiedValues(GlobalConstants consts,String errContext,int stmtIndex,UnifiedValues unified) throws OptUnsafeError {
  int closedIndex=stmtIndex + 1;
  for (  Var closed : unified.closed) {
    markClosed(closed,closedIndex,false);
  }
  for (  Var closed : unified.recursivelyClosed) {
    markClosed(closed,closedIndex,true);
  }
  update(consts,errContext,unified.availableVals,null,stmtIndex);
}
Program: 132622
Project: 132622
Buggy source:
private void compileTopLevel(GlobalContext context,LocatedModule mainModule) throws UserException, UndefinedFunctionException, ModuleLoadException {
  Pair<ParsedModule,Boolean> loadedMainModule=modules.loadIfNeeded(context,mainModule);
  assert(!loadedMainModule.val2);
  varAnalyzer.walkTopLevel(context,loadedMainModule.val1.ast,moduleIterator(context));
  backend.startFunction(Constants.ENTRY_FUNCTION,Var.NONE,Var.NONE,ExecTarget.syncControl());
  for (  LocatedModule loadedModule : modules.loadedModules()) {
    loadModule(context,FrontendPass.COMPILE_TOPLEVEL,loadedModule);
  }
  FunctionType mainFn=context.lookupFunction(Constants.MAIN_FUNCTION);
  if (mainFn != null) {
    backend.functionCall(Constants.MAIN_FUNCTION,Constants.MAIN_FUNCTION,Arg.NONE,Var.NONE,ExecTarget.syncControl(),new TaskProps());
  }
  backend.endFunction();
}

Fixed version (ground truth):
private void compileTopLevel(GlobalContext context,LocalContext topLevelContext,LocatedModule mainModule) throws UserException, UndefinedFunctionException, ModuleLoadException {
  Pair<ParsedModule,Boolean> loadedMainModule=modules.loadIfNeeded(context,mainModule);
  assert(!loadedMainModule.val2);
  varAnalyzer.walkTopLevel(context,loadedMainModule.val1.ast,moduleIterator(context));
  backend.startFunction(Constants.ENTRY_FUNCTION,Var.NONE,Var.NONE,ExecTarget.syncControl());
  for (  LocatedModule loadedModule : modules.loadedModules()) {
    loadModule(context,topLevelContext,FrontendPass.COMPILE_TOPLEVEL,loadedModule);
  }
  FunctionType mainFn=context.lookupFunction(Constants.MAIN_FUNCTION);
  if (mainFn != null) {
    backend.functionCall(Constants.MAIN_FUNCTION,Constants.MAIN_FUNCTION,Arg.NONE,Var.NONE,ExecTarget.syncControl(),new TaskProps());
  }
  backend.endFunction();
}
Program: 132623
Project: 132623
Buggy source:
private void compileFunctions(GlobalContext context) throws ModuleLoadException, UserException {
  for (  LocatedModule loadedModule : modules.loadedModules()) {
    loadModule(context,FrontendPass.COMPILE_FUNCTIONS,loadedModule);
  }
}

Fixed version (ground truth):
private void compileFunctions(GlobalContext context,LocalContext topLevelContext) throws ModuleLoadException, UserException {
  for (  LocatedModule loadedModule : modules.loadedModules()) {
    loadModule(context,topLevelContext,FrontendPass.COMPILE_FUNCTIONS,loadedModule);
  }
}
Program: 132624
Project: 132624
Buggy source:
private void walkTopLevel(GlobalContext context,SwiftAST fileTree,FrontendPass pass) throws UserException {
  if (pass == FrontendPass.DEFINITIONS) {
    walkTopLevelDefs(context,fileTree);
  }
 else   if (pass == FrontendPass.COMPILE_TOPLEVEL) {
    walkTopLevelCompileStatements(context,fileTree);
  }
 else {
    assert(pass == FrontendPass.COMPILE_FUNCTIONS);
    walkTopLevelCompileFunctions(context,fileTree);
  }
}

Fixed version (ground truth):
private void walkTopLevel(GlobalContext context,LocalContext topLevelContext,SwiftAST fileTree,FrontendPass pass) throws UserException {
  if (pass == FrontendPass.DEFINITIONS) {
    walkTopLevelDefs(context,topLevelContext,fileTree);
  }
 else   if (pass == FrontendPass.COMPILE_TOPLEVEL) {
    walkTopLevelCompileStatements(topLevelContext,fileTree);
  }
 else {
    assert(pass == FrontendPass.COMPILE_FUNCTIONS);
    walkTopLevelCompileFunctions(context,fileTree);
  }
}
Program: 132625
Project: 132625
Buggy source:
/** 
 * Handle an import statement by loading definitions for, or compiling module as needed.
 * @param context
 * @param tree
 * @param pass
 * @throws UserException
 */
private void importModule(GlobalContext context,SwiftAST tree,FrontendPass pass) throws UserException {
  assert(tree.getType() == ExMParser.IMPORT);
  assert(tree.getChildCount() == 1);
  SwiftAST moduleID=tree.child(0);
  if (pass == FrontendPass.DEFINITIONS) {
    LocatedModule module=LocatedModule.fromModuleNameAST(context,moduleID,false);
    loadModule(context,pass,module);
  }
}

Fixed version (ground truth):
/** 
 * Handle an import statement by loading definitions for, or compiling module as needed.
 * @param context
 * @param tree
 * @param pass
 * @throws UserException
 */
private void importModule(GlobalContext context,LocalContext topLevelContext,SwiftAST tree,FrontendPass pass) throws UserException {
  assert(tree.getType() == ExMParser.IMPORT);
  assert(tree.getChildCount() == 1);
  SwiftAST moduleID=tree.child(0);
  if (pass == FrontendPass.DEFINITIONS) {
    LocatedModule module=LocatedModule.fromModuleNameAST(context,moduleID,false);
    loadModule(context,topLevelContext,pass,module);
  }
}
Program: 132626
Project: 132626
Buggy source:
/** 
 * Second pass: - Compile top-level statements
 * @param globalContext
 * @param fileTree
 * @throws UserException
 */
private void walkTopLevelCompileStatements(GlobalContext globalContext,SwiftAST fileTree) throws UserException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  Context context=LocalContext.topLevelContext(globalContext);
  syncFilePos(context,fileTree);
  List<SwiftAST> stmts=new ArrayList<SwiftAST>();
  for (  SwiftAST stmt : fileTree.children()) {
    syncFilePos(context,stmt);
    int type=stmt.getType();
    if (TopLevel.isStatement(type)) {
      stmts.add(stmt);
    }
 else     if (!TopLevel.isDefinition(type)) {
      throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
    }
  }
  for (  SwiftAST stmt : stmts) {
    walkStatement(context,stmt,WalkMode.NORMAL);
  }
}

Fixed version (ground truth):
/** 
 * Second pass: - Compile top-level statements
 * @param globalContext
 * @param fileTree
 * @throws UserException
 */
private void walkTopLevelCompileStatements(LocalContext context,SwiftAST fileTree) throws UserException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  List<SwiftAST> stmts=new ArrayList<SwiftAST>();
  for (  SwiftAST stmt : fileTree.children()) {
    syncFilePos(context,stmt);
    int type=stmt.getType();
    if (TopLevel.isStatement(type)) {
      stmts.add(stmt);
    }
 else     if (!TopLevel.isDefinition(type)) {
      throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
    }
  }
  for (  SwiftAST stmt : stmts) {
    walkStatement(context,stmt,WalkMode.NORMAL);
  }
}
Program: 132627
Project: 132627
Buggy source:
/** 
 * First pass: - Register (but don't compile) all functions and other definitions
 * @param context
 * @param fileTree
 * @throws UserException
 * @throws DoubleDefineException
 * @throws UndefinedTypeException
 */
private void walkTopLevelDefs(GlobalContext context,SwiftAST fileTree) throws UserException, DoubleDefineException, UndefinedTypeException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  for (  SwiftAST stmt : fileTree.children()) {
    int type=stmt.getType();
    syncFilePos(context,stmt);
switch (type) {
case ExMParser.IMPORT:
      importModule(context,stmt,FrontendPass.DEFINITIONS);
    break;
case ExMParser.DEFINE_BUILTIN_FUNCTION:
  defineBuiltinFunction(context,stmt);
break;
case ExMParser.DEFINE_FUNCTION:
defineFunction(context,stmt);
break;
case ExMParser.DEFINE_APP_FUNCTION:
defineAppFunction(context,stmt);
break;
case ExMParser.DEFINE_NEW_STRUCT_TYPE:
defineNewStructType(context,stmt);
break;
case ExMParser.DEFINE_NEW_TYPE:
case ExMParser.TYPEDEF:
defineNewType(context,stmt,type == ExMParser.TYPEDEF);
break;
case ExMParser.GLOBAL_CONST:
globalConst(context,stmt);
break;
case ExMParser.PRAGMA:
pragmaTopLevel(context,stmt);
break;
case ExMParser.EOF:
break;
default :
if (!TopLevel.isStatement(type)) {
throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
}
}
}
}

Fixed version (ground truth):
/** 
 * First pass: - Register (but don't compile) all functions and other definitions
 * @param context
 * @param fileTree
 * @throws UserException
 * @throws DoubleDefineException
 * @throws UndefinedTypeException
 */
private void walkTopLevelDefs(GlobalContext context,LocalContext topLevelContext,SwiftAST fileTree) throws UserException, DoubleDefineException, UndefinedTypeException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  for (  SwiftAST stmt : fileTree.children()) {
    int type=stmt.getType();
    syncFilePos(context,stmt);
switch (type) {
case ExMParser.IMPORT:
      importModule(context,topLevelContext,stmt,FrontendPass.DEFINITIONS);
    break;
case ExMParser.DEFINE_BUILTIN_FUNCTION:
  defineBuiltinFunction(context,stmt);
break;
case ExMParser.DEFINE_FUNCTION:
defineFunction(context,stmt);
break;
case ExMParser.DEFINE_APP_FUNCTION:
defineAppFunction(context,stmt);
break;
case ExMParser.DEFINE_NEW_STRUCT_TYPE:
defineNewStructType(context,stmt);
break;
case ExMParser.DEFINE_NEW_TYPE:
case ExMParser.TYPEDEF:
defineNewType(context,stmt,type == ExMParser.TYPEDEF);
break;
case ExMParser.GLOBAL_CONST:
globalConst(context,stmt);
break;
case ExMParser.PRAGMA:
pragmaTopLevel(context,stmt);
break;
case ExMParser.EOF:
break;
default :
if (!TopLevel.isStatement(type)) {
throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
}
}
}
}
Program: 132628
Project: 132628
Buggy source:
/** 
 * Walk the statements in a file.
 * @param context
 * @param module the parsed file to compile
 * @param pass controls whether we just load top-level defs, or whetherwe attempt to compile the module
 * @throws UserException
 */
private void walkFile(GlobalContext context,LocatedModule module,ParsedModule parsed,FrontendPass pass) throws UserException {
  LogHelper.debug(context,"String_Node_Str" + module.canonicalName + "String_Node_Str"+ pass);
  modules.enterModule(module,parsed);
  walkTopLevel(context,parsed.ast,pass);
  modules.exitModule();
  LogHelper.debug(context,"String_Node_Str" + module.canonicalName + "String_Node_Str"+ pass);
}

Fixed version (ground truth):
/** 
 * Walk the statements in a file.
 * @param context
 * @param module the parsed file to compile
 * @param pass controls whether we just load top-level defs, or whetherwe attempt to compile the module
 * @throws UserException
 */
private void walkFile(GlobalContext context,LocalContext topLevelContext,LocatedModule module,ParsedModule parsed,FrontendPass pass) throws UserException {
  LogHelper.debug(context,"String_Node_Str" + module.canonicalName + "String_Node_Str"+ pass);
  modules.enterModule(module,parsed);
  walkTopLevel(context,topLevelContext,parsed.ast,pass);
  modules.exitModule();
  LogHelper.debug(context,"String_Node_Str" + module.canonicalName + "String_Node_Str"+ pass);
}
Program: 132629
Project: 132629
Buggy source:
/** 
 * Compile or load definitions for a module (depending on pass), if needed. Avoids double-compiling or double loading a module.
 * @param context
 * @param pass
 * @param module
 * @throws ModuleLoadException
 * @throws UserException
 */
private void loadModule(GlobalContext context,FrontendPass pass,LocatedModule module) throws ModuleLoadException, UserException {
  Pair<ParsedModule,Boolean> loaded=modules.loadIfNeeded(context,module);
  ParsedModule parsed=loaded.val1;
  boolean newlyLoaded=loaded.val2;
  if (pass == FrontendPass.DEFINITIONS) {
    if (newlyLoaded) {
      if (LogHelper.isDebugEnabled()) {
        LogHelper.debug(context,"String_Node_Str" + module.canonicalName);
        LogHelper.debug(context,parsed.ast.printTree());
      }
      walkFile(context,module,parsed,pass);
    }
  }
 else {
    assert(pass == FrontendPass.COMPILE_FUNCTIONS || pass == FrontendPass.COMPILE_TOPLEVEL);
    assert(!newlyLoaded);
    walkFile(context,module,parsed,pass);
  }
}

Fixed version (ground truth):
/** 
 * Compile or load definitions for a module (depending on pass), if needed. Avoids double-compiling or double loading a module.
 * @param context
 * @param pass
 * @param module
 * @throws ModuleLoadException
 * @throws UserException
 */
private void loadModule(GlobalContext context,LocalContext topLevelContext,FrontendPass pass,LocatedModule module) throws UserException {
  Pair<ParsedModule,Boolean> loaded=modules.loadIfNeeded(context,module);
  ParsedModule parsed=loaded.val1;
  boolean newlyLoaded=loaded.val2;
  if (pass == FrontendPass.DEFINITIONS) {
    if (newlyLoaded) {
      if (LogHelper.isDebugEnabled()) {
        LogHelper.debug(context,"String_Node_Str" + module.canonicalName);
        LogHelper.debug(context,parsed.ast.printTree());
      }
      walkFile(context,topLevelContext,module,parsed,pass);
    }
  }
 else {
    assert(pass == FrontendPass.COMPILE_FUNCTIONS || pass == FrontendPass.COMPILE_TOPLEVEL);
    assert(!newlyLoaded);
    walkFile(context,topLevelContext,module,parsed,pass);
  }
}
Program: 132630
Project: 132630
Buggy source:
private void loadDefinitions(GlobalContext context,LocatedModule mainModule,LocatedModule builtins) throws ModuleLoadException, UserException {
  loadModule(context,FrontendPass.DEFINITIONS,builtins);
  loadModule(context,FrontendPass.DEFINITIONS,mainModule);
}

Fixed version (ground truth):
private void loadDefinitions(GlobalContext context,LocalContext topLevelContext,LocatedModule mainModule,LocatedModule builtins) throws ModuleLoadException, UserException {
  loadModule(context,topLevelContext,FrontendPass.DEFINITIONS,builtins);
  loadModule(context,topLevelContext,FrontendPass.DEFINITIONS,mainModule);
}
Program: 132631
Project: 132631
Buggy source:
/** 
 * Walk the AST and make calls to backend to generate lower level code. This function is called to start the walk at the top level file
 * @param mainFilePath the main file path to process
 * @param originalMainFilePath original main file, in case a temporary fileis being directly parsed
 * @param preprocessed true if module was preprocessed
 * @throws UserException
 */
public void walk(String mainFilePath,String originalMainFilePath,boolean preprocessed) throws UserException {
  GlobalContext context=new GlobalContext(mainFilePath,Logging.getSTCLogger(),foreignFuncs);
  String mainModuleName=FilenameUtils.getBaseName(originalMainFilePath);
  LocatedModule mainModule=new LocatedModule(mainFilePath,mainModuleName,preprocessed);
  LocatedModule builtins=LocatedModule.fromPath(context,Arrays.asList("String_Node_Str"),false);
  loadDefinitions(context,mainModule,builtins);
  compileTopLevel(context,mainModule);
  compileFunctions(context);
}

Fixed version (ground truth):
/** 
 * Walk the AST and make calls to backend to generate lower level code. This function is called to start the walk at the top level file
 * @param mainFilePath the main file path to process
 * @param originalMainFilePath original main file, in case a temporary fileis being directly parsed
 * @param preprocessed true if module was preprocessed
 * @throws UserException
 */
public void walk(String mainFilePath,String originalMainFilePath,boolean preprocessed) throws UserException {
  GlobalContext context=new GlobalContext(mainFilePath,Logging.getSTCLogger(),foreignFuncs);
  LocalContext topLevelContext=LocalContext.topLevelContext(context);
  String mainModuleName=FilenameUtils.getBaseName(originalMainFilePath);
  LocatedModule mainModule=new LocatedModule(mainFilePath,mainModuleName,preprocessed);
  LocatedModule builtins=LocatedModule.fromPath(context,Arrays.asList("String_Node_Str"),false);
  loadDefinitions(context,topLevelContext,mainModule,builtins);
  compileTopLevel(context,topLevelContext,mainModule);
  compileFunctions(context,topLevelContext);
}
Program: 132632
Project: 132632
Buggy source:
public static FunctionCall fromAST(Context context,SwiftAST tree,boolean doWarn) throws UserException {
  assert(tree.getChildCount() >= 2);
  SwiftAST fTree=tree.child(0);
  String f;
  if (fTree.getType() == ExMParser.DEPRECATED) {
    fTree=fTree.child(0);
    assert(fTree.getType() == ExMParser.ID);
    f=fTree.getText();
    if (doWarn) {
      LogHelper.warn(context,"String_Node_Str" + f + "String_Node_Str");
    }
  }
 else {
    assert(fTree.getType() == ExMParser.ID);
    f=fTree.getText();
  }
  SwiftAST arglist=tree.child(1);
  DefInfo def=context.lookupDef(f);
  List<SwiftAST> annotations=tree.children(2);
  if (def.kind == DefKind.FUNCTION) {
    FunctionType ftype=context.lookupFunction(f);
    assert(ftype != null);
    return regularFunctionFromAST(context,annotations,f,arglist,ftype);
  }
 else   if (def.kind == DefKind.TYPE) {
    Type type=context.lookupTypeUnsafe(f);
    assert(type != null);
    if (Types.isStruct(type)) {
      return structConstructorFromAST(context,annotations,f,arglist,type);
    }
  }
  throw UndefinedFunctionException.unknownFunction(context,f);
}

Fixed version (ground truth):
public static FunctionCall fromAST(Context context,SwiftAST tree,boolean doWarn) throws UserException {
  assert(tree.getChildCount() >= 2);
  SwiftAST fTree=tree.child(0);
  String f;
  if (fTree.getType() == ExMParser.DEPRECATED) {
    fTree=fTree.child(0);
    assert(fTree.getType() == ExMParser.ID);
    f=fTree.getText();
    if (doWarn) {
      LogHelper.warn(context,"String_Node_Str" + f + "String_Node_Str");
    }
  }
 else {
    assert(fTree.getType() == ExMParser.ID);
    f=fTree.getText();
  }
  SwiftAST arglist=tree.child(1);
  DefInfo def=context.lookupDef(f);
  List<SwiftAST> annotations=tree.children(2);
  if (def == null) {
    throw UndefinedFunctionException.unknownFunction(context,f);
  }
 else   if (def.kind == DefKind.FUNCTION) {
    FunctionType ftype=context.lookupFunction(f);
    assert(ftype != null);
    return regularFunctionFromAST(context,annotations,f,arglist,ftype);
  }
 else   if (def.kind == DefKind.TYPE) {
    Type type=context.lookupTypeUnsafe(f);
    assert(type != null);
    if (Types.isStruct(type)) {
      return structConstructorFromAST(context,annotations,f,arglist,type);
    }
  }
  throw new TypeMismatchException(f + "String_Node_Str" + "String_Node_Str");
}
Program: 132633
Project: 132633
Buggy source:
/** 
 * Fix up any variables missing from the usedVariables passed through continuations. This is useful because it is easier to write other optimizations if they are allowed to mess up the usedVariables
 * @param updateLists modify tree and update pass and keep open lists
 */
public static void fixupProgram(Logger logger,Program prog,boolean updateLists){
  Set<Var> referencedGlobals=new HashSet<Var>();
  for (  Function fn : prog.getFunctions()) {
    if (updateLists) {
      fixupFunction(logger,prog.constants(),prog.globalVars(),fn,referencedGlobals,FixupVarMode.REBUILD);
      fixupFunction(logger,prog.constants(),prog.globalVars(),fn,referencedGlobals,FixupVarMode.ADD);
    }
 else {
      fixupFunction(logger,prog.constants(),prog.globalVars(),fn,referencedGlobals,FixupVarMode.NO_UPDATE);
    }
  }
  if (updateLists)   removeUnusedGlobals(prog.constants(),referencedGlobals);
}

Fixed version (ground truth):
/** 
 * Fix up any variables missing from the usedVariables passed through continuations. This is useful because it is easier to write other optimizations if they are allowed to mess up the usedVariables
 * @param updateLists modify tree and update pass and keep open lists
 */
public static void fixupProgram(Logger logger,Program prog,boolean updateLists){
  Set<Var> referencedGlobals=new HashSet<Var>();
  for (  Function fn : prog.getFunctions()) {
    if (updateLists) {
      fixupFunction(logger,prog.constants(),prog.globalVars(),fn,referencedGlobals,FixupVarMode.REBUILD);
      fixupFunction(logger,prog.constants(),prog.globalVars(),fn,referencedGlobals,FixupVarMode.ADD);
    }
 else {
      fixupFunction(logger,prog.constants(),prog.globalVars(),fn,referencedGlobals,FixupVarMode.NO_UPDATE);
    }
  }
  if (updateLists)   removeUnusedGlobals(prog.constants(),prog.globalVars(),referencedGlobals);
}
Program: 132634
Project: 132634
Buggy source:
private static void removeUnusedGlobals(GlobalConstants constants,Set<Var> referencedGlobals){
  Set<Var> globNames=new HashSet<Var>(constants.map().keySet());
  globNames.removeAll(referencedGlobals);
  for (  Var unused : globNames) {
    constants.remove(unused);
  }
}

Fixed version (ground truth):
private static void removeUnusedGlobals(GlobalConstants constants,GlobalVars globalVars,Set<Var> referencedGlobals){
  Set<Var> globalsToRemove=new HashSet<Var>();
  globalsToRemove.addAll(constants.map().keySet());
  globalsToRemove.addAll(globalVars.vars());
  globalsToRemove.removeAll(referencedGlobals);
  for (  Var unused : globalsToRemove) {
    if (unused.storage() == Alloc.GLOBAL_CONST) {
      constants.remove(unused);
    }
 else {
      assert(unused.storage() == Alloc.GLOBAL_VAR);
      globalVars.removeVariable(unused);
    }
  }
}
Program: 132635
Project: 132635
Buggy source:
/** 
 * Try to hoist this instruction
 * @param logger
 * @param inst
 * @param state
 * @return true if hoisted
 */
private boolean tryHoist(Logger logger,Instruction inst,HoistTracking state){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + inst + "String_Node_Str"+ state.maxHoist+ "String_Node_Str"+ state.maxLoopHoist);
  }
  if (!inst.canChangeTiming()) {
    logger.trace("String_Node_Str");
    return false;
  }
  int maxHoist=state.maxHoist;
  for (  Arg in : inst.getInputs()) {
    if (maxHoist <= 0)     return false;
    if (in.isVar()) {
      Var inVar=in.getVar();
      maxHoist=Math.min(maxHoist,maxInputHoist(logger,state,inVar));
      if (!Semantics.canPassToChildTask(inVar)) {
        return false;
      }
    }
  }
  for (  Var readOutput : inst.getReadOutputs()) {
    int inputHoist=maxInputHoist(logger,state,readOutput);
    maxHoist=Math.min(maxHoist,inputHoist);
    logger.trace("String_Node_Str" + inputHoist + "String_Node_Str"+ readOutput.name());
  }
  for (  Var out : inst.getOutputs()) {
    if (!Semantics.canPassToChildTask(out)) {
      return false;
    }
    if (trackDeclares(out)) {
      int declareDepth=state.declareMap.getDepth(out);
      if (logger.isTraceEnabled())       logger.trace("String_Node_Str" + out + "String_Node_Str"+ declareDepth);
      assert(declareDepth >= 0);
      if (declareDepth > state.maxLoopHoist && !inst.isIdempotent()) {
        maxHoist=Math.min(maxHoist,state.maxLoopHoist);
        if (logger.isTraceEnabled())         logger.trace("String_Node_Str" + state.maxLoopHoist);
      }
    }
  }
  for (  Var out : inst.getPiecewiseAssignedOutputs()) {
    if (!inst.isIdempotent()) {
      maxHoist=Math.min(maxHoist,state.maxLoopHoist);
      if (logger.isTraceEnabled())       logger.trace("String_Node_Str" + out + "String_Node_Str"+ "String_Node_Str"+ state.maxLoopHoist);
    }
  }
  for (  Var out : inst.getOutputs()) {
    if (Types.outputRequiresInitialization(out)) {
      if (!inst.isInitialized(out)) {
        int initDepth=state.initializedMap.getDepth(out);
        if (logger.isTraceEnabled())         logger.trace("String_Node_Str" + initDepth + "String_Node_Str"+ "String_Node_Str"+ out);
        maxHoist=Math.min(maxHoist,initDepth);
        return false;
      }
    }
  }
  if (logger.isTraceEnabled())   logger.trace("String_Node_Str" + maxHoist);
  if (maxHoist <= 0) {
    return false;
  }
  int maxCorrectContext=maxHoistContext(logger,state,inst.execMode(),maxHoist);
  maxHoist=Math.max(maxHoist,maxCorrectContext);
  if (maxHoist <= 0) {
    return false;
  }
  doHoist(logger,inst,maxHoist,state);
  return true;
}

Fixed version (ground truth):
/** 
 * Try to hoist this instruction
 * @param logger
 * @param inst
 * @param state
 * @return true if hoisted
 */
private boolean tryHoist(Logger logger,Instruction inst,HoistTracking state){
}
Program: 132636
Project: 132636
Buggy source:
/** 
 * Called once all usage info is collected
 * @return violations if this is a struct and it is incompletely specified
 */
public List<Violation> isIncompletelyDefinedStruct(Context context){
  if (Types.isStruct(this.type)) {
    ArrayList<Violation> result=new ArrayList<Violation>();
    Ternary assigned=isAssigned();
    if (assigned == Ternary.TRUE) {
      return result;
    }
 else     if (assigned == Ternary.MAYBE && isRead() != Ternary.FALSE) {
      result.add(new Violation(ViolationType.WARNING,this.getName() + "String_Node_Str",context));
    }
    for (    VInfo vi : structFields.values()) {
      if (vi.isAssigned() != Ternary.TRUE) {
        if (vi.isAssigned() == Ternary.FALSE && vi.isRead() == Ternary.TRUE) {
          result.add(new Violation(ViolationType.ERROR,"String_Node_Str" + vi.getName() + "String_Node_Str"+ "String_Node_Str",context));
        }
 else         if (assigned != Ternary.FALSE) {
          result.add(new Violation(ViolationType.WARNING,vi.getName() + "String_Node_Str" + "String_Node_Str",context));
        }
      }
      List<Violation> more=vi.isIncompletelyDefinedStruct(context);
      if (more != null)       result.addAll(more);
    }
    return result;
  }
 else {
    return null;
  }
}

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

Fixed version (ground truth):
private List<Violation> structAssign(Context context,List<String> fieldPath,int arrayDepth,AssignOp op){
  VInfo fieldVInfo;
  List<Violation> errs=new ArrayList<Violation>();
  if (structFields != null) {
    if (this.assigned == Ternary.TRUE) {
      return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + fieldPath + "String_Node_Str"+ this.name+ "String_Node_Str",context));
    }
 else     if (this.assigned == Ternary.MAYBE) {
      errs.add(new Violation(ViolationType.WARNING,"String_Node_Str" + fieldPath + "String_Node_Str"+ this.name+ "String_Node_Str",context));
    }
    String field=fieldPath.get(0);
    if (structFields.containsKey(field)) {
      fieldVInfo=structFields.get(field);
    }
 else {
      return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + field + "String_Node_Str"+ this.name+ "String_Node_Str"+ ((StructType)type).getStructTypeName(),context));
    }
  }
 else {
    return Arrays.asList(new Violation(ViolationType.ERROR,"String_Node_Str" + this.name + "String_Node_Str",context));
  }
  fieldPath.remove(0);
  errs.addAll(fieldVInfo.assign(context,fieldPath,arrayDepth,op));
  return errs;
}
Program: 132638
Project: 132638
Buggy source:
private static Type unpackedStructType(Type type,StructType structType){
  List<StructField> packedFields=structType.getFields();
  List<StructField> unpackedFields=new ArrayList<StructField>(packedFields.size());
  boolean differences=false;
  for (  StructField packedField : packedFields) {
    Type packedFieldType=packedField.getType();
    Type unpackedFieldType=unpackedType(packedFieldType);
    if (unpackedFieldType.equals(packedFieldType)) {
      unpackedFields.add(packedField);
    }
 else {
      StructField unpackedField=new StructField(unpackedFieldType,packedField.getName());
      unpackedFields.add(unpackedField);
      differences=true;
    }
  }
  if (differences) {
    return new StructType(true,"String_Node_Str" + type.typeName(),unpackedFields);
  }
 else {
    return StructType.localStruct(structType);
  }
}

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

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

Fixed version (ground truth):
/** 
 * Retrieve a struct directly to a local struct, without following any references
 * @param dst
 * @param src non-recursively closed struct
 * @return
 */
public static Instruction retrieveStruct(Var dst,Var src){
}
Program: 132641
Project: 132641
Buggy source:
private static Type unpackedStructType(Type type,StructType structType){
  List<StructField> packedFields=structType.getFields();
  List<StructField> unpackedFields=new ArrayList<StructField>(packedFields.size());
  boolean differences=false;
  for (  StructField packedField : packedFields) {
    Type packedFieldType=packedField.getType();
    Type unpackedFieldType=unpackedType(packedFieldType);
    if (unpackedFieldType.equals(packedFieldType)) {
      unpackedFields.add(packedField);
    }
 else {
      StructField unpackedField=new StructField(unpackedFieldType,packedField.getName());
      unpackedFields.add(unpackedField);
      differences=true;
    }
  }
  if (differences) {
    return new StructType(true,"String_Node_Str" + type.typeName(),unpackedFields);
  }
 else {
    return structType;
  }
}

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

Fixed version (ground truth):
/** 
 * The type that would result from a retrieve operation
 * @param t
 * @return
 */
public static Type retrievedType(Typed t,boolean recursive){
  if (isScalarFuture(t) || isScalarUpdateable(t)) {
    return new ScalarValueType(t.type().primType());
  }
 else   if (isFile(t)) {
    return new FileValueType(t.type().fileKind());
  }
 else   if (isRef(t)) {
    return t.type().baseType().memberType();
  }
 else   if (recursive && (isContainer(t) || isContainerLocal(t))) {
    return unpackedType(t);
  }
 else   if (isArray(t)) {
    assert(!recursive);
    ArrayType at=(ArrayType)t.type().getImplType();
    Type retrievedMemberType=retrievedType(at.memberType(),false);
    return ArrayType.localArray(at.keyType(),retrievedMemberType);
  }
 else   if (isBag(t)) {
    assert(!recursive);
    BagType bt=(BagType)t.type().getImplType();
    Type retrievedMemberType=retrievedType(bt.memberType(),false);
    return BagType.localBag(retrievedMemberType);
  }
 else   if (isStruct(t)) {
    StructType st=(StructType)t.type().getImplType();
    if (recursive) {
      return unpackedType(st);
    }
 else {
      return StructType.localStruct(st);
    }
  }
 else {
    throw new STCRuntimeError(t.type() + "String_Node_Str");
  }
}
Program: 132644
Project: 132644
Buggy source:
private List<Violation> arrayAssign(Context context,int arrayDepth,AssignOp op){
  if (assigned != Ternary.FALSE) {
    if (arrayAssignDepth != arrayDepth) {
      return Arrays.asList(makeArrDepthViolation(context,arrayDepth));
    }
    this.assigned=Ternary.TRUE;
  }
 else {
    this.assigned=Ternary.TRUE;
    arrayAssignDepth=arrayDepth;
  }
  return Collections.emptyList();
}

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

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

Fixed version (ground truth):
private VInfo(Type type,boolean mapped,boolean locallyDeclared,String name,Ternary assigned,Ternary read,Ternary appended,int maxReadDepth){
  this.type=type;
  this.hasMapping=mapped;
  if (Types.isStruct(type)) {
    structFields=new HashMap<String,VInfo>();
    for (    StructField f : ((StructType)type.getImplType()).getFields()) {
      VInfo fieldVInfo=new VInfo(f.getType(),mapped,name + "String_Node_Str" + f.getName(),locallyDeclared);
      structFields.put(f.getName(),fieldVInfo);
    }
  }
 else {
    structFields=null;
  }
  this.declaredInCurrentScope=locallyDeclared;
  this.name=name;
  this.assigned=assigned;
  this.appended=appended;
  this.read=read;
  this.maxReadDepth=maxReadDepth;
}
Program: 132648
Project: 132648
Buggy source:
private Var derefOrCopyResult(Context context,Var lookupResult,Var outVar) throws UndefinedTypeException, UserException {
  try {
    if (outVar == null) {
      return lookupResult;
    }
 else     if (Types.isAssignableRefTo(lookupResult.type(),outVar.type())) {
      dereference(context,outVar,lookupResult);
      return outVar;
    }
 else {
      copyByValue(context,outVar,lookupResult);
      return outVar;
    }
  }
 catch (  RuntimeException e) {
    Logging.getSTCLogger().debug("String_Node_Str" + lookupResult + "String_Node_Str"+ outVar);
    throw e;
  }
}

Fixed version (ground truth):
private Var derefOrCopyResult(Context context,Var lookupResult,Var outVar) throws UndefinedTypeException, UserException {
  try {
    if (outVar == null) {
      return lookupResult;
    }
 else     if (Types.isRefTo(lookupResult.type(),outVar.type())) {
      dereference(context,outVar,lookupResult);
      return outVar;
    }
 else {
      copyByValue(context,outVar,lookupResult);
      return outVar;
    }
  }
 catch (  RuntimeException e) {
    Logging.getSTCLogger().debug("String_Node_Str" + lookupResult + "String_Node_Str"+ outVar);
    throw e;
  }
}