I get this error message:
testbench.vhd:16:22: no function declarations for operator \"+\"
at this line:
Z &
The error message is pretty clear. There is no function declarations for operator "+" which can add two unsigneds together and return a std_logic_vector. In the package numeric_std, there is however an opertor "+" which can add two unsigneds together and return an unsigned.
So, if you add another type conversion to convert the result of the addition back to a std_logic_vector the compiler can choose the version of the "+" operator that returns an unsigned.
Z <= std_logic_vector(unsigned(X) + unsigned(Y));
Overloading only works if there is exactly one fit for function, procedure or operator. If there is less than one, then there is no version for the compiler to choose; if there is more than one, the compiler doesn't know which one to choose and there is an ambiguity which needs to be sorted out.
Actually, you don't need to resize Y: the "+" operator is happy as long as one of the operands is the same width as the result.
https://www.edaplayground.com/x/4VJE