[Issue 23302] New: std.algorithm.comparison.predSwitch producing SwitchError with error message as the filename

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 22 19:36:57 UTC 2022


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 at puremagic.com
          Reporter: artha at 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 at 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

--


More information about the Digitalmars-d-bugs mailing list