semantic: Add ref handling in foreaching over aggregates.