I don't know why it doesnt work but you could just write the intrinsic to a string/int attribute before and then use the uniquevals function after. That's probably still more convenient and faster than using python.
Also typename is a string, so declaring your foo array as an int would, if the function would work with intrinsics, result in an array with a bunch of -1s I think.