Idorobots / spartan

A small Lisp dialect that serves me as a test bed for programming language features.
MIT License
14 stars 3 forks source link

`freevars` retains more free variables than exist in the code after optimization #146

Closed Idorobots closed 3 years ago

Idorobots commented 3 years ago

Running the following code results in x2 undefined variable reference in the result.

(list
 (let ((x1 '7)) (if (= '0 x1) 't nil))
 (let ((x2 '7)) (if (= '0 x2) nil 't)))

The x2 variable is optimized out by constant propagation, but somehow it survives in free vars until closure conversion creates the undefined reference.