The mystery is why simply calling your functon seems to trigger an attempt to recompile an Oracle-supplied type.
Does the type actually need recompiling? Is your package valid? Perhaps it is invalid and so calling it triggers an automatic recompilation, but I don't know why the type would be dependent on the package.
ORA-02311: cannot alter with COMPILE option a valid type with type or table dependents
Cause: An attempt was made to ALTER with COMPILE option a type that is valid and has type or table dependents.
Action: No need to perform this operation.
ORA-29861: domain index is marked LOADING/FAILED/UNUSABLE
Cause: An attempt has been made to access a domain index that is being built or is marked failed by an unsuccessful DDL or is marked unusable by a DDL operation.
Action: Wait if the specified index is marked LOADING Drop the specified index if it is marked FAILED Drop or rebuild the specified index if it is marked UNUSABLE.
You don't have PLSQL_COMPILER_FLAGS set to DEBUG or something do you? I'm still not sure how it would cause this though.