Fix #1020: Proper stack frame resolution in anonymous functions