Mercerenies / gdlisp

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

Copy-on-write resources don't assign correctly when localized #68

Closed Mercerenies closed 2 years ago

Mercerenies commented 2 years ago
(set $MyNode:color:a 0.5)

If this is the last expression in a function body, it compiles to

var _assign_0 = $MyNode.color
_assign_0.a = 0.5
return _assign_0.a

Unfortunately, colors and vectors are copy-on-write, so this doesn't actually change $MyNode.color like it's intended to.

Mercerenies commented 2 years ago

Note: We have a similar, related problem when closing around COW variables.

(let ((foo (vector 0 0 0)))
  (funcall (lambda () (set foo:x 100)))
  (print foo:x))

This will erroneously print 0, when it should print 100.

Mercerenies commented 2 years ago

Closed in 3c18a6d