Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 22708 - Extend semantic for switch statements with invalid values #13617

Merged
merged 1 commit into from Mar 2, 2022

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Feb 7, 2022

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.

This effectively restores some of the semantic disabled by #13309 in the case of an invalid switch value


Best viewed with disabled whitespace diff. More examples of invalid code using switch statements would be appreciated, I'll also try to come up with some more test cases.

CC @schveiguy

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @MoonlightSentinel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
22708 minor switch statement with an undefined symbol results in many errors

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#13617"

src/dmd/statementsem.d Outdated Show resolved Hide resolved
@MoonlightSentinel MoonlightSentinel force-pushed the overzealous-switch-error branch 2 times, most recently from 253845c to 0e4d396 Compare February 7, 2022 19:59
@MoonlightSentinel MoonlightSentinel changed the title Fix 22708 - Extends semantic for switch statements with invalid values Fix 22708 - Extend semantic for switch statements with invalid values Feb 7, 2022
@MoonlightSentinel MoonlightSentinel marked this pull request as ready for review February 19, 2022 17:52
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.
src/dmd/statementsem.d Show resolved Hide resolved
@RazvanN7 RazvanN7 merged commit 160e3eb into dlang:stable Mar 2, 2022
@MoonlightSentinel MoonlightSentinel deleted the overzealous-switch-error branch March 2, 2022 10:12
@MartinNowak MartinNowak mentioned this pull request Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants