Mercerenies / gdlisp

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

Duplicate Usage of Labels in Closure #130

Open Mercerenies opened 1 year ago

Mercerenies commented 1 year ago
(labels ((foo () (bar)) (bar () (foo)))
  (lambda () (foo) (bar)))

This produces a closure object that incorrectly uses the _locals name twice.

class _LambdaBlock extends GDLisp.Function:

    var _locals
    var _locals

    func _init(_locals, _locals):
        self._locals = _locals
        self._locals = _locals
        self.__gdlisp_required = 0
        self.__gdlisp_optional = 0
        self.__gdlisp_rest = 0

    func call_func():
        _locals._fn_foo_1()
        return _locals._fn_bar_0()

    func call_funcv(args):
        if args == null:
            return call_func()
        else:
            push_error("Too many arguments")

It's the same _locals object, so we only need it once. And this is a syntax error in GDScript right now.