Possible internal bug for list manipulations

Possible internal bug for list manipulations

I have two functions that both should do the same thing.

Here's Function 1
  1. int COUNT_BY_ID_ALT(list PRI_LIST)
  2. {
  3.     //use samples CRA,BIR should be 263
  4.     n = 0;
  5.     UNIQUE_ID_LIST = List();
  6.     for each element in input.PRI_LIST
  7.     {
  8.         ID_LIST = (SUBSCRIBERS[LISTS.contains(element)].ID).getall();
  9.         for each ID_element in ID_LIST
  10.         {
  11.             //makes unique list of ID's
  12.             if (!UNIQUE_ID_LIST.contains(ID_element))
  13.             {
  14.                 UNIQUE_ID_LIST.add(ID_element);
  15.             }
  16.         }
  17.     }
  18.     return UNIQUE_ID_LIST.size();
  19. }
And Function 2
  1. int COUNT_BY_ID(list PRI_LIST)
  2. {
  3.     //use samples CRA,BIR should be 263
  4.     n = 0;
  5.     UNIQUE_ID_LIST = List:String();
  6.     for each element in input.PRI_LIST
  7.     {
  8.         ID_LIST = (SUBSCRIBERS[LISTS.contains(element)].ID).getall();
  9.         for each ID_element in ID_LIST
  10.         {
  11.             //makes unique list of ID's
  12.             if (!UNIQUE_ID_LIST.contains(ID_element))
  13.             {
  14.                 UNIQUE_ID_LIST.add(ID_element.toString());
  15.             }
  16.         }
  17.     }
  18.     return UNIQUE_ID_LIST.size();
  19. }
Function 1 returns the expected result from my test set (263) while Function 2 returns a larger number (275). Analysis of the results shows Function 2's " makes unique list of ID's" loop is duplicating some strings in a predictable fashion. The only difference between these two functions is that in Function 2, I'm treating record ID numbers as strings. 

Line 13 in Function 2 is where the thing fails. If I make it

  1.  if (!UNIQUE_ID_LIST.contains(ID_element.toString()))
then the function works. This is why I think there's an internal bug. Either Creator should tell me that I cannot compare strings to long or the internal string comparison is broken on your server's side.

In any case, I'm using Function 1 in my app, but I thought you should know about this.

Cheers,
John Whitney