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

Additional arguments bound in a connect call that do not match the expected type on the receiving function fail silently #53680

Open
mikemherron opened this issue Oct 11, 2021 · 1 comment

Comments

@mikemherron
Copy link

Godot version

3.3.2.stable.official

System information

Windows 10

Issue description

If additional arguments bound to a connect call do not match the expected type on the receiving function, they will be passed as null with no other error or runtime warning. I would expect at least an error to be reported in this case, similar to how errors are reported when the number of arguments on the function do no match the number provided at run time.

Steps to reproduce

See below code from the provided sample that reproduces the issue. Run the project, and press the button - 'Invalid get index 'some_data' (on base :'Nil').' will be reported as object is passed is as null - but I'd argue what should happen here is the signal handling function should not be called, an an error reported instead.

extends Node2D

var my_object : MyClass

func _ready():
	my_object = MyClass.new()
	my_object.some_data = "testing"
	
	#In the below connect call, we bind my_object, an instance of
	#MyClass, to the even handler invocation, but the handler function
	#expects an instance of MyOtherClass. This fails silently with "null"
	#being passed in to _on_button_press.
	
	# warning-ignore:return_value_discarded
	$Button.connect("button_down", self, "_on_button_press", [my_object])

func _on_button_press(object : MyOtherClass) -> void:
	print(object.some_data)

class MyClass extends Object:
	var some_data : String
	
class MyOtherClass extends Object:
	var some_data : String
	

Minimal reproduction project

TestConnectWrongType.zip

@mikemherron mikemherron changed the title Additional arguments bound to a connect that do not match the expected type on the receiving function fails silently Additional arguments bound in a connect call that do not match the expected type on the receiving function fail silently Oct 11, 2021
@kleonc
Copy link
Member

kleonc commented Oct 11, 2021

Possibly a duplicate of #37312 (which seems to be fixed only for master).

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

No branches or pull requests

3 participants