I agree with @dragonforge-dev and @normalized.
Case: Let us think like a totally beginner.
Beginners typically won’t change the settings, meaning Untyped Declaration will retain the default “Ignore” at first.
For example, if we already have two functions here before:
func foo():
pass
func foo_return():
return 1
Then, when I set the Untyped Declaration to “Error”:
We got errors! Let’s fix it.
The original Godot GDScript rules is very clear and straightforward.
Beginner just need simply adds some meaningful type keywords (“-> void”, " → int", etc…) to each function.
Since no return indicates “no return value", just add"→ void".
func foo() → void:
pass
Since return an int indicates “int return value”, just add"→ int".
func foo_return() → int:
return 1
No error here, and beginners can finish modification easily and quickly.
But, the @codingus version may cause the following obfuscations.
Based on @codingus’s logic, beginner may think like:
Since no return indicates “no return value".
Since no -> sometype: indicates “no return value".
It can be inferred, so No Need to change.
It’s totally the same as no changed (Beginner may confuse here, Is this function typed?)…
func foo():
pass
Based on @codingus’s logic, beginner may think like:
(1). It can be inferred. Since no -> sometype: indicates “no return value”…
(2). It can be inferred. Since the function returns an int indicates “int return value”…
So, how to determine? Use (2), but why?
In fact, no matter which one. Since may have to determine from more than one choices, it will use more time to do this. And for beginner, it means have more confused.
func foo_return() -> int:
return 1
No error here, but beginner may confuse why sometimes have to add “-> sometype”, but sometimes no change ? What actually means if “Untyped Declaration set to Error”?
So, If I can choose, I like Godot’s original way.