-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94076 from AThousandShips/lambda_get_method_fix
[GDScript] Fix `get_method` for lambda self `Callable`s
- Loading branch information
Showing
4 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
modules/gdscript/tests/scripts/runtime/features/lambda_get_method.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# https://github.com/godotengine/godot/issues/94074 | ||
|
||
func foo(): | ||
pass | ||
|
||
func test(): | ||
var lambda_self := func test() -> void: | ||
foo() | ||
var anon_lambda_self := func() -> void: | ||
foo() | ||
|
||
print(lambda_self.get_method()) # Should print "test". | ||
print(anon_lambda_self.get_method()) # Should print "<anonymous lambda>". | ||
|
||
var lambda_non_self := func test() -> void: | ||
pass | ||
var anon_lambda_non_self := func() -> void: | ||
pass | ||
|
||
print(lambda_non_self.get_method()) # Should print "test". | ||
print(anon_lambda_non_self.get_method()) # Should print "<anonymous lambda>". |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/runtime/features/lambda_get_method.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
GDTEST_OK | ||
test | ||
<anonymous lambda> | ||
test | ||
<anonymous lambda> |