Capture temporary local variables in async context. Fixes #10341