www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23302] New: std.algorithm.comparison.predSwitch producing

https://issues.dlang.org/show_bug.cgi?id=23302

          Issue ID: 23302
           Summary: std.algorithm.comparison.predSwitch producing
                    SwitchError with error message as the filename
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: artha samerion.com

In this example
```
import std.algorithm;

void main() 
{

    writeln(
        0.predSwitch(
            1, "Hello, World!"
        )
    );

}
```
The following SwitchError will be thrown:
```
core.exception.SwitchError Input not matched by any pattern(1968): No
appropriate switch clause found
```
Incorrectly, predSwitch supplies the error message into the filename parameter.
This likely happens because SwitchError does not take a message parameter (see:
https://github.com/dlang/dmd/blob/33e8f2ce32831d509fb9052227ca9f33e132a29b/druntime/src/core/exception.d#L449).

Found with a DMD64 D Compiler v2.100.0 on Linux

--
Aug 22 2022