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

No constructor of "int" matches the signature "int(null)". #104

Open
amap1380 opened this issue Dec 28, 2022 · 3 comments
Open

No constructor of "int" matches the signature "int(null)". #104

amap1380 opened this issue Dec 28, 2022 · 3 comments
Labels

Comments

@amap1380
Copy link

Godot version: Godot 4.0 beta 10
addon version: godot 4 branch 3b61520
running the project will result an error in IntType.gd Line 12

@amap1380
Copy link
Author

removing the int constructor will resolve the issue

@quentincaffeino
Copy link
Owner

Thanks for reporting! Will fix

@hilfazer
Copy link
Contributor

Removing the integer cast will make the code incorrect as the function is supposed to return an int.

There's something interesting i've just learned. GDScript's static analyzer can determine function's return type based on its code, return type specifier isn't necessary. Thus the following function will have return type of null:

# @param    Variant  value
# @returns  String|null
func _reextract(value):
	var rematch = self._regex.search(value)

	if rematch and rematch is RegExMatch:
		return rematch.get_string()
	
	return null
	

Which is the reason for this error. I got rid of the error by doing this instead:

	if rematch and rematch is RegExMatch:
		return rematch.get_string()
	else:
		return null

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

No branches or pull requests

3 participants