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

Add warnings/error to ensure variables and method return/params use static typing #7689

Closed
JamesC01 opened this issue Sep 16, 2023 · 3 comments
Labels

Comments

@JamesC01
Copy link

Describe the project you are working on

Games.

Describe the problem or limitation you are having in your project

Sometimes for small projects, you might not want to use static typing, to save time. But as projects get bigger, it can be very helpful. The issue is when you move to static typing, a lot of the time you forget to use it when declaring variables and functions. Typing = instead of := and forgetting the types for the parameters of a method and its return type. It's nice to switch back and forth from dynamic and static depending on the project, so having warnings would force you to not forget about typing when working with it.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add warnings/errors in the project settings that warns you whenever you declare variables, methods etc. without a type would be very useful. There's always probably other things that violate type-safety that I'm forgetting, too, that could use warnings.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the projects settings > Debug > GDscript, there could be a set of new type-safety warnings to enable. It would also be useful to split the type warnings into a sub-section, so you can see them all in one place.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This would have to be part of the engine.

Is there a reason why this should be core and not an add-on in the asset library?

I'm not sure if addons can do something like this.

@JamesC01 JamesC01 changed the title Add warnings/error when not setting a variables type or method return type Add warnings/error when not setting a variable or method return type. Sep 16, 2023
@JamesC01 JamesC01 changed the title Add warnings/error when not setting a variable or method return type. Add warnings/error to ensure variables and method return/params have a type. Sep 16, 2023
@JamesC01 JamesC01 changed the title Add warnings/error to ensure variables and method return/params have a type. Add warnings/error to ensure variables and method return/params use static typing Sep 16, 2023
@AThousandShips
Copy link
Member

@AThousandShips
Copy link
Member

@JamesC01
Copy link
Author

JamesC01 commented Sep 16, 2023

Already done in 4.x:

Oh, awesome! Sorry for the duplicate, I did search, but it's right at the bottom of the closed issues, and I didn't see it. So strange that we both had the same idea 4 days within eachother. edit: never mind, it was just the pull request was 4 days ago, the actual proposal was years ago. Still strange that it was completed so closely to when I thought of this, though.

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

2 participants