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 a check for arguments with optional basic types and a non-null default #86

Open
Gama11 opened this issue Mar 1, 2016 · 0 comments

Comments

@Gama11
Copy link
Member

Gama11 commented Mar 1, 2016

In almost all cases of code that looks like this, the author is not aware that ? implicitly turns basic types into Null<T> (non-basic types too, but that shouldn't really have any run-time implications for those).

function foo(?arg:Int = 0)  {} // the user probably didn't want a nullable type here

Nullable basic types on their own are fine, but them being nullable is pointless if they have a non-null default value as well. You can't get the argument to be null anyway (see here).

Note that there may be a use-case for nullable basic types with default-values if you want them to be skippable (skipping is only allowed for nullable arguments).

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

1 participant