UUID array declared in stored procedure, on access throws explicit type casts needed
Change the assignment operator to := or use select into

create table t (id uuid);
insert into t values 
('672124b6-9894-11e5-be38-001d42e813fe'::uuid),
('672124b6-9894-11e5-be38-001d42e813fe'::uuid),
('672124b6-9894-11e5-be38-001d42e813fe'::uuid),
('672124b6-9894-11e5-be38-001d42e813fe'::uuid);




create or replace function test_array2()
returns uuid[] as
$$
declare
    ar uuid[];
begin
    select array_agg(id) from t into ar;
    return ar;
end
$$
language plpgsql;

select * from test_array2();




create or replace function test_array3()
returns uuid[] as
$$
declare
    ar uuid[];
begin
    ar := array(select array_agg(id) from t);
    return ar;
end
$$
language plpgsql;

select * from test_array3();




✓

| test_array3                                                                                                                                             |
| :------------------------------------------------------------------------------------------------------------------------------------------------------ |
| {{672124b6-9894-11e5-be38-001d42e813fe,672124b6-9894-11e5-be38-001d42e813fe,672124b6-9894-11e5-be38-001d42e813fe,672124b6-9894-11e5-be38-001d42e813fe}} |



db&lt;>fiddle here