Thread overview
[Issue 19087] `final switch` cannot be used in -betterC
Aug 15, 2018
Seb
Aug 15, 2018
Seb
Aug 16, 2018
Mathias LANG
Aug 16, 2018
Mike Franklin
Aug 24, 2018
Mike Franklin
Aug 24, 2018
Mike Franklin
Jan 15, 2023
Walter Bright
August 15, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

Seb <greensunny12@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greensunny12@gmail.com

--- Comment #1 from Seb <greensunny12@gmail.com> ---
> It should probably be an `assert`.

Agreed! `final switch` is actually usable in `nothrow` code (see e.g. https://run.dlang.io/is/mjVbPr), s.t. there's no reason to throw an exception.

Also programming errors are typically handled by `assert`.

--
August 15, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

--- Comment #2 from Seb <greensunny12@gmail.com> ---
A start for a discussion: https://github.com/dlang/druntime/pull/2274

--
August 16, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #3 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Wasn't the plan to make this a compile-time error, or does it needs to be a runtime error ?

--
August 16, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

--- Comment #4 from Mike Franklin <slavo5150@yahoo.com> ---
I'm not sure how to make it a compile-time error.  For example the code could be...

void test(int p)
{
 final switch (p)
 {
   case 42:
     break;
 }
}

void main()
{
    import core.stdc.stdlib;
    test(rand());
}

How can we predict what `rand()` will return.  And I don't think it's practical to enumerate all 2^32 possibilities for `int`.  Though maybe I'm missing something.

--
August 24, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Mike Franklin <slavo5150@yahoo.com> ---
PR attempting to address this issue: https://github.com/dlang/druntime/pull/2274

--
August 24, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC

--
October 22, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

--- Comment #6 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/druntime

https://github.com/dlang/druntime/commit/9cbdab897846781b69bd9dd88d43748b3e5dcc4e Fix Issue 19087 -  final switch cannot be used in -betterC

https://github.com/dlang/druntime/commit/7f62a68164bdb573bb705b2bed95e2bc7379f296 Merge pull request #2274 from wilzbach/fix-19087

[RFC] Issue 19087 - final switch cannot be used in -betterC

--
October 22, 2018
https://issues.dlang.org/show_bug.cgi?id=19087

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
January 15, 2023
https://issues.dlang.org/show_bug.cgi?id=19087

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=19172

--