Fixes for @for and @each (#12600, #9976)

- support for @for and @each in functions
- support for more complicated lists as parameter for @each

Change-Id: Iad7d8bad6c2b02497b8783accf90203fa43abfdb