maybe a noreturn issue

Dennis dkorpel at gmail.com
Tue Dec 3 13:06:01 UTC 2024


On Tuesday, 3 December 2024 at 12:41:18 UTC, Basile B. wrote:
> What's you're position ?

I often see suggestions to raise warnings/errors for ostensibly 
'useless constructs', such as unused parameters, if (0), strongly 
pure functions returning void etc.

In my experience, doing this rarely catches any actual bugs. 
Instead you'll end up bumping into such warnings/errors as 
annoying false positives, and then you realise that these 
constructs are, in fact, useful at times.

For example, unused parameters (and unnecessarily loose return 
types) can turn up when:
- The signature needs to match a callback (e.g. a thread function 
may not return, even though the signature allows returning a 
status code)
- A parameter / return value is no longer needed / reserved for 
future use, but signature is part of stable API
- int f(int x) => assert(0, "unimplemented");

So I'm not a fun of such a rule.


More information about the Digitalmars-d-learn mailing list