Program: 11012
Project: 11012
Buggy source:
public Object internalVisitFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext ctx){
  FunctionDef fun=of.createFunctionDef().withAccessLevel(parseAccessModifier(ctx.accessModifier())).withName(parseString(ctx.identifier()));
  if (ctx.operandDefinition() != null) {
    for (    cqlParser.OperandDefinitionContext opdef : ctx.operandDefinition()) {
      TypeSpecifier typeSpecifier=parseTypeSpecifier(opdef.typeSpecifier());
      fun.getOperand().add((OperandDef)of.createOperandDef().withName(parseString(opdef.identifier())).withOperandTypeSpecifier(typeSpecifier).withResultType(typeSpecifier.getResultType()));
    }
  }
  TypeSpecifier resultType=null;
  if (ctx.typeSpecifier() != null) {
    resultType=parseTypeSpecifier(ctx.typeSpecifier());
  }
  if (!libraryBuilder.getTranslatedLibrary().contains(fun)) {
    if (ctx.functionBody() != null) {
      libraryBuilder.beginFunctionDef(fun);
      try {
        libraryBuilder.pushExpressionContext(currentContext);
        try {
          fun.setExpression(parseExpression(ctx.functionBody()));
        }
  finally {
          libraryBuilder.popExpressionContext();
        }
      }
  finally {
        libraryBuilder.endFunctionDef();
      }
      if (resultType != null && fun.getExpression() != null && fun.getExpression().getResultType() != null) {
        if (!DataTypes.subTypeOf(fun.getExpression().getResultType(),resultType.getResultType())) {
          throw new IllegalArgumentException(String.format("String_Node_Str",fun.getName(),resultType.getResultType(),fun.getExpression().getResultType()));
        }
      }
      fun.setResultType(fun.getExpression().getResultType());
    }
 else {
      fun.setExternal(true);
      if (resultType == null) {
        throw new IllegalArgumentException(String.format("String_Node_Str",fun.getName()));
      }
      fun.setResultType(resultType.getResultType());
    }
    fun.setContext(currentContext);
    if (fun.getResultType() != null) {
      libraryBuilder.addExpression(fun);
    }
  }
  return fun;
}

Fixed version (ground truth):
public Object internalVisitFunctionDefinition(@NotNull cqlParser.FunctionDefinitionContext ctx){
  FunctionDef fun=of.createFunctionDef().withAccessLevel(parseAccessModifier(ctx.accessModifier())).withName(parseString(ctx.identifier()));
  if (ctx.operandDefinition() != null) {
    for (    cqlParser.OperandDefinitionContext opdef : ctx.operandDefinition()) {
      TypeSpecifier typeSpecifier=parseTypeSpecifier(opdef.typeSpecifier());
      fun.getOperand().add((OperandDef)of.createOperandDef().withName(parseString(opdef.identifier())).withOperandTypeSpecifier(typeSpecifier).withResultType(typeSpecifier.getResultType()));
    }
  }
  TypeSpecifier resultType=null;
  if (ctx.typeSpecifier() != null) {
    resultType=parseTypeSpecifier(ctx.typeSpecifier());
  }
  if (!libraryBuilder.getTranslatedLibrary().contains(fun)) {
    if (ctx.functionBody() != null) {
      libraryBuilder.beginFunctionDef(fun);
      try {
        libraryBuilder.pushExpressionContext(currentContext);
        try {
          libraryBuilder.pushExpressionDefinition(String.format("String_Node_Str",fun.getName()));
          try {
            fun.setExpression(parseExpression(ctx.functionBody()));
          }
  finally {
            libraryBuilder.popExpressionDefinition();
          }
        }
  finally {
          libraryBuilder.popExpressionContext();
        }
      }
  finally {
        libraryBuilder.endFunctionDef();
      }
      if (resultType != null && fun.getExpression() != null && fun.getExpression().getResultType() != null) {
        if (!DataTypes.subTypeOf(fun.getExpression().getResultType(),resultType.getResultType())) {
          throw new IllegalArgumentException(String.format("String_Node_Str",fun.getName(),resultType.getResultType(),fun.getExpression().getResultType()));
        }
      }
      fun.setResultType(fun.getExpression().getResultType());
    }
 else {
      fun.setExternal(true);
      if (resultType == null) {
        throw new IllegalArgumentException(String.format("String_Node_Str",fun.getName()));
      }
      fun.setResultType(resultType.getResultType());
    }
    fun.setContext(currentContext);
    if (fun.getResultType() != null) {
      libraryBuilder.addExpression(fun);
    }
  }
  return fun;
}