This particular case arose during work on the information schema:
-- good
select cast(55::oid AS varchar);varchar
---------55
(1 row)
-- bad
create domain test as varchar;
CREATE DOMAIN
select cast(55::oid AS test);
ERROR: Cannot cast type oid to test
--
Peter Eisentraut peter_e@gmx.net