Bug 23302 – std.algorithm.comparison.predSwitch producing SwitchError with error message as the filename
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-08-22T19:36:57Z
Last change time
2022-08-24T10:54:52Z
Keywords
pull
Assigned to
No Owner
Creator
artha
Comments
Comment #0 by artha — 2022-08-22T19:36:57Z
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
@RazvanN7 created dlang/dmd pull request #14381 "Fix Issue 23302 - std.algorithm.comparison.predSwitch producing SwitchError with error message as the filename" fixing this issue:
- Fix Issue 23302 - std.algorithm.comparison.predSwitch producing SwitchError with error message as the filename
https://github.com/dlang/dmd/pull/14381
Comment #3 by dlang-bot — 2022-08-24T10:54:52Z
dlang/dmd pull request #14381 "Fix Issue 23302 - std.algorithm.comparison.predSwitch producing SwitchError with error message as the filename" was merged into master:
- 3437e63662377ab60085eb0e01bebdef20da4ff4 by RazvanN7:
Fix Issue 23302 - std.algorithm.comparison.predSwitch producing SwitchError with error message as the filename
https://github.com/dlang/dmd/pull/14381