Program: 27695
Project: 27695
Buggy source:
private JSType evalMaprecord(Node ttlAst,NameResolver nameResolver){
  ImmutableList<Node> params=getCallParams(ttlAst);
  Node recParam=params.get(0);
  JSType recType=evalInternal(recParam,nameResolver);
  if (!recType.isRecordType()) {
    reportWarning(ttlAst,RECTYPE_INVALID,recType.toString());
    return getUnknownType();
  }
  ObjectType objRecType=((ObjectType)recType);
  Set<String> ownPropsNames=objRecType.getOwnPropertyNames();
  Node mapFunction=params.get(1);
  String paramKey=getFunctionParameter(mapFunction,0);
  String paramValue=getFunctionParameter(mapFunction,1);
  if (nameResolver.nameVars.containsKey(paramKey)) {
    reportWarning(ttlAst,DUPLICATE_VARIABLE,paramKey);
    return getUnknownType();
  }
  if (nameResolver.typeVars.containsKey(paramValue)) {
    reportWarning(ttlAst,DUPLICATE_VARIABLE,paramValue);
    return getUnknownType();
  }
  Node mapFnBody=getFunctionBody(mapFunction);
  ImmutableMap.Builder<String,JSType> newPropsBuilder=new ImmutableMap.Builder<String,JSType>();
  for (  String propName : ownPropsNames) {
    JSType propValue=objRecType.getSlot(propName).getType();
    NameResolver newNameResolver=new NameResolver(addNewEntry(nameResolver.typeVars,paramValue,propValue),addNewEntry(nameResolver.nameVars,paramKey,propName));
    JSType mapFnBodyResult=evalInternal(mapFnBody,newNameResolver);
    if (mapFnBodyResult.isNoType()) {
      continue;
    }
    if (!mapFnBodyResult.isRecordType()) {
      reportWarning(ttlAst,MAPRECORD_BODY_INVALID,mapFnBodyResult.toString());
      return getUnknownType();
    }
    ObjectType mapFnBodyAsObjType=((ObjectType)mapFnBodyResult);
    for (    String newPropName : mapFnBodyAsObjType.getOwnPropertyNames()) {
      JSType newPropValue=mapFnBodyAsObjType.getSlot(newPropName).getType();
      newPropsBuilder.put(newPropName,newPropValue);
    }
  }
  return createRecordType(newPropsBuilder.build());
}

Fixed version (ground truth):
private JSType evalMaprecord(Node ttlAst,NameResolver nameResolver){
  ImmutableList<Node> params=getCallParams(ttlAst);
  Node recParam=params.get(0);
  JSType recType=evalInternal(recParam,nameResolver);
  if (!recType.isRecordType()) {
    reportWarning(ttlAst,RECTYPE_INVALID,recType.toString());
    return getUnknownType();
  }
  ObjectType objRecType=((ObjectType)recType);
  Set<String> ownPropsNames=objRecType.getOwnPropertyNames();
  Node mapFunction=params.get(1);
  String paramKey=getFunctionParameter(mapFunction,0);
  String paramValue=getFunctionParameter(mapFunction,1);
  if (nameResolver.nameVars.containsKey(paramKey)) {
    reportWarning(ttlAst,DUPLICATE_VARIABLE,paramKey);
    return getUnknownType();
  }
  if (nameResolver.typeVars.containsKey(paramValue)) {
    reportWarning(ttlAst,DUPLICATE_VARIABLE,paramValue);
    return getUnknownType();
  }
  Node mapFnBody=getFunctionBody(mapFunction);
  Map<String,JSType> newProps=new HashMap<String,JSType>();
  for (  String propName : ownPropsNames) {
    JSType propValue=objRecType.getSlot(propName).getType();
    NameResolver newNameResolver=new NameResolver(addNewEntry(nameResolver.typeVars,paramValue,propValue),addNewEntry(nameResolver.nameVars,paramKey,propName));
    JSType mapFnBodyResult=evalInternal(mapFnBody,newNameResolver);
    if (mapFnBodyResult.isNoType()) {
      continue;
    }
    if (!mapFnBodyResult.isRecordType()) {
      reportWarning(ttlAst,MAPRECORD_BODY_INVALID,mapFnBodyResult.toString());
      return getUnknownType();
    }
    ObjectType mapFnBodyAsObjType=((ObjectType)mapFnBodyResult);
    for (    String newPropName : mapFnBodyAsObjType.getOwnPropertyNames()) {
      JSType newPropValue=mapFnBodyAsObjType.getSlot(newPropName).getType();
      putNewPropInPropertyMap(newProps,newPropName,newPropValue);
    }
  }
  return createRecordType(new ImmutableMap.Builder<String,JSType>().putAll(newProps).build());
}