Yearly "can we please have void foo() auto" post
Basile B.
b2.temp at gmx.com
Thu Jul 27 20:05:43 UTC 2023
On Thursday, 27 July 2023 at 15:22:45 UTC, Anonymouse wrote:
> I love `auto`, it makes my life easier. The compiler infers
> what it can and I primarily enjoy the bonuses of `@safe`
> without having to annotate it manually.
>
> But it's not always applicable.
>
> [...]
>
> 3. Any void function that I don't want the tooling to nag about.
>
> ```d
> auto foo() {}
>
> /*
> asdf.d(3:1)[warn]: Auto function without return statement,
> prefer replacing auto with void
> */
For this you can (and should) open a D-Scanner PR that proposes
to deactivate the check by default. The rationale for this check
(IIRC) is that if you have an `asm` block that returns something
then the compiler infers void as return type. A quite rare case
actually... Unfortunately I did not thought to the attribute
problem when I wrote the check, a long time ago.
More information about the Digitalmars-d
mailing list