-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access member variable from lambda body due cyclic reference #70592
Comments
From the mention of autoload, possible duplicate of #70495 |
@RobertBorghese Notwithstanding the possible duplicate, please join a minimal reproduction project when code is needed to demonstrate the issue, even if the code seems simple. It's so much easier for the developers to unzip the project and run it, rather than to create a new project and copy-paste the code. |
Apologies for bad reporting, this occurs without autoload as well. Updated original post.
No problem! Updated post with minimal project! 👌 |
CC @rune-scape Seems related to this code: godot/modules/gdscript/gdscript_analyzer.cpp Lines 240 to 248 in b6e0603
|
Just ran into this issue myself while playing around with Godot 4.0 stable. Small sample code to demonstrate: var stats = {
health = 100
}
var actions = {
hit = func(damage := 1):
stats.health -= damage
if (stats.health <= 0):
actions.die()
, die = func():
queue_free()
} This currently errors on |
Godot version
4.0.beta10
System information
Windows 10
Issue description
For top-level class variables, a lambda stored in a dictionary cannot reference the dictionary members.
Steps to reproduce
Assuming
MyAutoload.gd
is an autoload class, this code that worked in beta 8, no longer works in beta 10.Autoload is unrelated however, just wanted to demonstrate how there's an inconsistent error if this is intended behavior. The following occurs regardless of autoload. If the "MyAutoload" part is removed from the lambda, a "cyclic reference" error occurs.
Minimal reproduction project
Issue_70592_BugProject.zip
The text was updated successfully, but these errors were encountered: