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

warn for useless parameter storage classes #850

Open
WebFreak001 opened this issue Nov 26, 2021 · 1 comment
Open

warn for useless parameter storage classes #850

WebFreak001 opened this issue Nov 26, 2021 · 1 comment

Comments

@WebFreak001
Copy link
Member

See https://dlang.org/spec/function.html#parameters

Storage Class Description
scope The parameter must not escape the function call (e.g. by being assigned to a global variable). Ignored for any parameter that is not a reference type.
return Parameter may be returned or copied to the first parameter, but otherwise does not escape from the function. Such copies are required not to outlive the argument(s) they were derived from. Ignored for parameters with no references. See Scope Parameters.
@rikkimax
Copy link
Contributor

rikkimax commented Feb 5, 2023

It should also warn on scope return, as the correct order recognized by the compiler is return scope. Same order for ref.

This is something I keep doing wrong.

However on the function itself its a lot more complicated and there is no "correct" order: https://dlang.org/spec/function.html#ref-return-scope-parameters

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

No branches or pull requests

2 participants