Skip to content
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

GDScript: Fix lambda resolution with cyclic references #80923

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Aug 23, 2023

  • Closes Cannot access member variable from lambda body due cyclic reference #70592.
  • This PR allows lambda body to use class members in any order (but you still have to consider the order in which initializer expressions are evaluated if they call lambdas).
  • The lambda signature is still respected in member resolution (because argument initializers don't have to be literals).
  • call() arguments should also not create cyclic references, as they are part of the outer expression, not part of lambda body.

@dalexeev dalexeev added this to the 4.2 milestone Aug 23, 2023
@dalexeev dalexeev requested a review from a team as a code owner August 23, 2023 09:41
@dalexeev dalexeev force-pushed the gds-fix-lambda-body-cyclic-ref-resolution branch 3 times, most recently from 494cfcf to 3d24aa4 Compare August 23, 2023 15:06
Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems in order!

@dalexeev dalexeev force-pushed the gds-fix-lambda-body-cyclic-ref-resolution branch from 3d24aa4 to 89429b0 Compare August 25, 2023 13:29
@YuriSizov YuriSizov merged commit 548bfa8 into godotengine:master Aug 25, 2023
15 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@dalexeev dalexeev deleted the gds-fix-lambda-body-cyclic-ref-resolution branch August 25, 2023 19:54
@rune-scape
Copy link
Contributor

im curious if the lambda body resolution could be delayed until the very end of the current scope, (class, function, script) without any issues

@dalexeev
Copy link
Member Author

dalexeev commented Jan 4, 2024

Lambda body resolution is delayed until the end of the member variable definition (otherwise you cannot call the lambda recursively) and until the end of the statement in the case of local expressions, not until the end of the class/function. No problems found so far, let me know if you find one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot access member variable from lambda body due cyclic reference
4 participants