fix Issue 12523 - wrong type deduced for foreach ref argument

- take storage class const/immutable/inout from element type modifier