Diagnostics for redundant qualifiers

Paul Backus snarwin at gmail.com
Wed Jul 28 19:07:08 UTC 2021


On Wednesday, 28 July 2021 at 18:54:12 UTC, Per Nordlöw wrote:
> What about making
>
> ```d
> @safe struct S  {
>    void f() @safe {}
> }
> ```
>
> warn or deprecate as
>
> ```
> Warning: redundant function attribute `@safe`
> ```
>
> ?

What's the harm in allowing redundant attributes?

Generally, warnings are helpful when they point out code that is 
likely to do something different from what the programmer 
intended (e.g., `if (a = b)`). If the programmer wrote `@safe` in 
two places, I'd say there's very little chance they did it by 
mistake.


More information about the Digitalmars-d mailing list