Mercerenies / gdlisp

Lisp on the Godot platform
GNU General Public License v3.0
140 stars 1 forks source link

Constants are incorrectly captured by class initializer #83

Open Mercerenies opened 2 years ago

Mercerenies commented 2 years ago
(defconst x 42)
(defclass Foo (Reference)
  (defvar x x)
  (defn _init ()))

The initializer for Foo.x will be incorrectly written as self.x = x, which does not assign the constant top-level value x to the instance variable.

In this case (where an instance variable shadows a const currently in scope), we should probably make another const with a synthetic name to get around the shadow.