-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
call_group() fails silently #32186
Comments
I did some tests and standard |
Can I work on this? |
@Chinmaygoyal Sure, why not. There's no need to ask for permission. |
After another look, this looks intended. When you call group, you call on multiple nodes and if it was throwing errors, you could potentially get lots of them on one call (like, you make a mistake and your debugger dies, because 1000 nodes got a wrong call). I think the proper way to "fix" this would be additional argument to optionally check if calls succeed or a warning when a call fails. EDIT: |
Still valid in v4.4.dev.custom_build [6681f25] With the addition of typed Dictionaries and Arrays this can be particularly confusing, because they are sometimes implicitly converted, seemingly, and sometimes not (such as arguments of a function). Consider: var dict :Dictionary = {1: Vector2i(1,2)}
var dict2 :Dictionary[int, Vector2i] = {1: Vector2i(1,2)}
var dict3 :Dictionary = dict2.duplicate(true)
print(dict.is_typed()) # false
print(dict2.is_typed()) # true
print(dict3.is_typed()) # true (implicit conversion ?) However in this MRP, the call will silently fail: extends Control
func _ready() -> void:
add_to_group(&"test_group")
var normal_dict :Dictionary = {0 : 1, 2 : 3}
get_tree().call_group(&"test_group", &"test_1", normal_dict) # No error, no warning, silent fail
var typed_dict :Dictionary[int, int] = {4 : 5, 6 : 7}
get_tree().call_group(&"test_group", &"test_1", typed_dict)
#test_1(normal_dict) # Prints error -> The dictionary of argument 1 (Dictionary) does not have the same element type as the expected typed dictionary argument.
#test_1(typed_dict)
func test_1(arg_dict :Dictionary[int, int]) -> void:
print("test 1 called")
print(arg_dict)
Maybe it's not a bug, but I think if the function name is correct and exists then something should be shown to the user, because is there a case where you'd want to call the correct function name with wrong arguments? |
Godot version:
3.1
Issue description:
call_group()
will silently fail if it is not passed the correct type for the args if they are statically typed, or passed an incorrect number of args. Ideally it should print something to console or error out if it's not able to call the function correctly, as it's difficult to figure out what's going wrong without that.Steps to reproduce:
prints to console
get_tree().call_group("Test", "test_me", "test")
fails silently
get_tree().call_group("Test", "test_me", 0)
get_tree().call_group("Test", "test_me")
error 'Invalid call to function 'test_me (via call)' in base 'Node (script.gd)'. Expected 1 arguments.
call("Test", "test_me")
error 'Invalid type in function 'test_me (via call)' in base 'Node (script.gd)'. Cannot convert argument 2 from int to String.
call("Test", "test_me", 0)
The text was updated successfully, but these errors were encountered: