fix Issue 12523 - wrong type deduced for foreach ref argument

- No need to change the storage class because the var type
  already has inferred modifiers.
Merge pull request #3424 from MartinNowak/fix12523

fix Issue 12523 - wrong type deduced for foreach ref argument