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

Setter function fails silently if called with incorrect type, assignment ignored without warning #48765

Closed
MFikretY opened this issue May 16, 2021 · 1 comment

Comments

@MFikretY
Copy link

Godot version:
3.3 stable

OS/device including version:
Windows 10

Issue description:
If the input type is defined for a setter function, it fails silently if given another type . No error is thrown, no warning given, and the assignment is completely ignored. Note that this only occurs if the setter is called implicitly, see steps below.

Steps to reproduce:

Upon defining a class like so:

class_name ObjectTest

var test_var : int = 10 setget test_set, test_get

func test_set(input_string : int):
	print("Set invoked")
	test_var = input_string
	
func test_get():
	print("Get invoked")
	return test_var

And calling from another script like so:

func _ready():
 	var obj = ObjectTest.new()
 	obj.test_var = "Hello"  # IGNORED
	print(obj.test_var)

The output is:

Get invoked
10

Note that "Set invoked" is not shown, so the setter has not run at all.

Project zip:
setter_bug.zip

@akien-mga
Copy link
Member

Fixed by #54117.

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