Thread overview
The forgotten deprecation: switch case fall-through
Dec 03, 2020
Bastiaan Veelo
Dec 13, 2020
kdevel
Dec 14, 2020
Bastiaan Veelo
December 03, 2020
Hi,

Switch case fallthrough (non-empty cases that do not end with a break, continue, goto, return, throw or assert(0) statement) has been deprecated for more than 9 years [1]. As I am fixing a bug due to unintended case fall-through today, I am wondering when its deprecation period will be ended. It is not in the list of deprecations [2]. Does this mean that it is being forgotten? Is there a protocol for what should happen to deprecations and when, and who is taking care of that process?

Had there been a -preview switch for making this an error, I'd be using it (I can't use -de just yet, as I need to allow other deprecations for the moment).

Thanks,
Bastiaan.

[1] https://github.com/dlang/dlang.org/commit/ae093a0e416821768260da799fe565654f48a5d6
[2] https://dlang.org/deprecate.html
December 13, 2020
On Thursday, 3 December 2020 at 09:29:12 UTC, Bastiaan Veelo wrote:
> Switch case fallthrough (non-empty cases that do not end with a break, continue, goto, return, throw or assert(0) statement) has been deprecated for more than 9 years [1]. As I am fixing a bug due to unintended case fall-through today, I am wondering when its deprecation period will be ended.

For the non-trivial ArgumentList case [1] it has not even startet yet

~~~switchbreak.d
int foo (string s)
{
   int a;
   switch (s) {
      case "eins", "zwei":
         a = 1;
      default: // no warning
   }
   return a;
}

int bar (string s)
{
   int a;
   switch (s) {
      case "eins": case "zwei":
         a = 2;
      default: // deprecation warning
   }
   return a;
}

unittest {
   assert (foo ("") == 0);
   assert (foo ("eins") == 1);
   assert (foo ("zwei") == 1);
   assert (bar ("") == 0);
   assert (bar ("eins") == 2);
   assert (bar ("zwei") == 2);
}
~~~

$ dmd -unittest -main -run switchbreak
switchbreak.d(18): Deprecation: switch case fallthrough - use 'goto default;' if intended
1 unittests passed


[1] https://dlang.org/spec/statement.html#switch-statement

December 14, 2020
On Sunday, 13 December 2020 at 20:45:55 UTC, kdevel wrote:
> On Thursday, 3 December 2020 at 09:29:12 UTC, Bastiaan Veelo wrote:
[...]
>> I am wondering when its deprecation period will be ended.
>
> For the non-trivial ArgumentList case [1] it has not even startet yet
>
> ~~~switchbreak.d
> int foo (string s)
> {
>    int a;
>    switch (s) {
>       case "eins", "zwei":
>          a = 1;
>       default: // no warning
>    }
>    return a;
> }

Oh dear!

— Bastiaan.