Issue 13120 - Body of `foreach` over string with transcoding ignores function attributes

https://issues.dlang.org/show_bug.cgi?id=13120

Based on the PR #3626.
Please add comment explaining why pure is in a comment. If it is inferred to be pure, then the comment should say that.