If it has visibility of local variables, then we are talking about a closure rather than a function and when you want to have closures in your language, you need to be wary of many factors, for example:
- Do you clone the values of the local vars as they were when the closure was created?
- Do you keep a reference or move them into the closure?
- Can the closure be freed? If so, how? You probably wouldn't want a memory leak
Solving these is probably beyond the scope of this language.