bottom type as parameter or local variable, does that make sense?
WebFreak001
d.forum at webfreak.org
Fri Jan 14 11:52:04 UTC 2022
For example:
```d
import std.stdio;
void foo(noreturn a)
{
writeln("we got called!");
}
void bar()
{
noreturn b;
writeln("calling");
foo(b);
}
void main()
{
writeln("bar");
bar();
writeln("done");
}
```
Guess what it prints and reply to it on this thread. I think the
result is pretty nonsensical.
Reveal: https://run.dlang.io/is/4SXQal
Should this usage be allowed? I would say not allowing it would
make more sense.
Additionally if we don't allow it we could allow aliasing to it
like:
```d
deprecated("OldType is no longer supported, use NewType instead")
alias OldType = noreturn;
```
and with that both add hint messages for users to migrate and not
allow broken code to compile.
A sample for this would be libdparse, where the arguments of the
visit functions determine which function is called, even if the
argument isn't actually used or just ignored. The cases where the
argument type is specified, but not used, do happen and migrating
types there to force the user to rewrite code is currently not
possible without completely removing the type.
More information about the Digitalmars-d
mailing list