tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

Using function local variables inside an anonymous function causes segmentation fault #68

Closed porky11 closed 8 years ago

porky11 commented 8 years ago

example:

(import stdlib)

(using-namespace std

(def main (fn extern-c void (void)
  (def var (var intern int 0)) ;if this is a global variable, it works
  (let ((fun \ (fn void (void)
          (incv var)
          (return))))
    (fun)
    (fun))))
)
tomhrr commented 8 years ago

This is now fixed. Anonymous functions should not have access to any variables outside their own scope, including variables defined within the function in which the anonymous function is defined.