A nested function (or perhaps an inline lambda) is needed to force the allocation of a dynamic context for the capture.This is an embarrassment. Why hasn't this been fixed yet? :-(T
I agree that this needs to get fixed immediately, it seems to be bugging me another time as well.
I believe I saw a similar StackOverflow post about this issue for C#, and Microsoft did fix it, hopefully D can do the same. Fixing this will improve the quality of the language for newcomers such as myself greatly.