yes, it could be - but hard to fix it, because it is based on cooperation two worlds - plpgsql and SQL - and it is sometimes not simple.
When you understand how plpgsql interpret use variables in SQL queries, then you understand to this message. Simple rule - never use plpgsql variables in DDL