Consider this code: ```d enum Foo { one, two } void main() { final switch(foo()) { // oops, forgot to define foo() case Foo.one: break; case Foo.two: break; } } ``` In addition to the correct error of "foo" not being defined, the compiler will emit nonsense errors based on the case statements. The error has changed throughout the years. for 2.097, the error is: Error: duplicate `case two` in `switch` statement Note the missing "Foo." prefix, no error about case `Foo.one`, and also, the nonsensical error. For 2.098.1, the error has changed to: Error: `case` must be a `string` or an integral constant, not `one` Error: `case` must be a `string` or an integral constant, not `two` Such errors should either be omitted, or adjusted to be less confusing.
@MoonlightSentinel created dlang/dmd pull request #13617 "Fix 22708 - Extends semantic for switch statements with invalid values" fixing this issue: - Fix 22708 - Extends semantic for switch statements with invalid values Only omitting the cast allows further semantic to perform the expected checks and transformations. This allows for better error detection that were not reported before and also avoids invalid errors due to missing `optimize` calls. https://github.com/dlang/dmd/pull/13617
@Panke updated dlang/dmd pull request #13755 "Fix Issue 21844: makedeps contain non-existing files" fixing this issue: - Fix 22708 - Extend semantic for switch statements with invalid values (#13617) Only omitting the cast allows further semantic to perform the expected checks and transformations. This allows for better error detection that were not reported before and also avoids invalid errors due to missing `optimize` calls. https://github.com/dlang/dmd/pull/13755
@MartinNowak created dlang/dmd pull request #13785 "merge stable" fixing this issue: - Fix 22708 - Extend semantic for switch statements with invalid values (#13617) Only omitting the cast allows further semantic to perform the expected checks and transformations. This allows for better error detection that were not reported before and also avoids invalid errors due to missing `optimize` calls. https://github.com/dlang/dmd/pull/13785
dlang/dmd pull request #13785 "merge stable" was merged into master: - 160e3ebeaed0448a81322b2c19a0ac156445d61e by Florian: Fix 22708 - Extend semantic for switch statements with invalid values (#13617) Only omitting the cast allows further semantic to perform the expected checks and transformations. This allows for better error detection that were not reported before and also avoids invalid errors due to missing `optimize` calls. https://github.com/dlang/dmd/pull/13785