In reply to dave_59:
If you want a count of then number of elements greater than 5, then you need to write
y=numbers.sum with (int'(item>5));
That’s because the type of item>5 is a 1-bit expression, and sum of 1-bit expressions is a 1-bit result.
This whole casting thing is ridiculous, since this is what users usually want and forget, leading to these kinds of questions on forums. I’d like to hear a compelling reason why the language designers specified things this way.