-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
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
get_method() is not returning the name of the lambda function #73052
Labels
Comments
I can confirm, at RC5
it ends up in a runtime error
|
MikeSchulze
added a commit
to MikeSchulze/gdUnit4
that referenced
this issue
Feb 25, 2023
# Why With RC3, RC4, RC3 some regressions are introduced and needs to be addapt to get GdUnit4 running # What - fix bug in releasing internal memory store - fix function doubling according to fixed issue (godotengine/godot#73046) - remove custom `is_instanceof` and replace it by new engine function `is_instance_of` - do code formattings - use new signal code style to connect/disconnect - use workaround for `GlobalScript` enums (godotengine/godot#73835) - use workaround for `Timer.timeout.connect` (godotengine/godot#73889) - use workarount for `Callable.get_method()` (godotengine/godot#73052)
MikeSchulze
added a commit
to MikeSchulze/gdUnit4
that referenced
this issue
Feb 25, 2023
# Why With RC3, RC4, RC3 some regressions are introduced and needs to be addapt to get GdUnit4 running # What - fix bug in releasing internal memory store - fix function doubling according to fixed issue (godotengine/godot#73046) - remove custom `is_instanceof` and replace it by new engine function `is_instance_of` - do code formattings - use new signal code style to connect/disconnect - use workaround for `GlobalScript` enums (godotengine/godot#73835) - use workaround for `Timer.timeout.connect` (godotengine/godot#73889) - use workarount for `Callable.get_method()` (godotengine/godot#73052) - switch to RC5 on ci-pr WF
It seems fixed on branch main, so I'm closing this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Godot version
4.0.rc
System information
Windows 10
Issue description
The documentation of the Callable.get_method() says:
"Returns the name of the method represented by this Callable. If the callable is a lambda function, returns the function's name."
However, this is not true, and the function always returns an empty string when the Callable is a lambda, named or not. Also, the string representation of the Callable, although not exactly wrong, seems to be different than the intended by the code.
I already have the solution for this bug, and the PR is ready to be opened. However, I would like to discuss two things before:
1. The current code has the following "if" in the get_as_text function to check if the lambda is an anonymous lambda:
if (function->get_name() != StringName())
However, it doesn't work because the function name is never empty; the GDScript parser always set it to
"<anonymous lambda>"
in these cases. So, the solution is an uglier, but functional:if (function->get_name() != "<anonymous lambda>")
2. There is a lot of duplicated code between the classes GDScriptLambdaCallable and GDScriptLambdaSelfCallable. Even this fix should be duplicated in both classes. Is it ok to refactor in order to make both classes inherit from a common base class, like GDScriptLambdaCallableBase? (My proposed fix already does that, actually.)
Steps to reproduce
Run the following GDScript:
This is the current result:
This is the expected result:
Notice that get_method is always returning empty currently.
Also, the str(lambda) expected result is what the code seems to by trying to do, but there is a wrong "if" there (as explained above).
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: