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 issue 23000 - final switch error has no line number with -checkaction=C #13971

Merged
merged 1 commit into from Apr 12, 2022

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Apr 10, 2022

The assert(0) for the default case of the final switch is generated in statementsem.d:

s = new ExpStatement(ss.loc, new AssertExp(ss.loc, IntegerExp.literal!0));

Then in e2ir.d, the location of the assert expression is used, which is IntegerExp.literal!0 in this case, which doesn't have a location set. This patch makes it use the location of the statement instead, which is actually consistent with the other checkactions since a D assert also uses the location of the statement.

I tested this manually, but not sure how to add this to the test suite because I can't catch a C assert, and I'm not sure we even want a new runnable test for something trivial like this, but I'm open to suggestions.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! 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
23000 normal final switch error has no line number with -checkaction=C

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 "master + dmd#13971"

@thewilsonator
Copy link
Contributor

Is is possible to write a test case for this?

@dkorpel
Copy link
Contributor Author

dkorpel commented Apr 11, 2022

Is is possible to write a test case for this?

I tested this manually, but not sure how to add this to the test suite because I can't catch a C assert, and I'm not sure we even want a new runnable test for something trivial like this, but I'm open to suggestions.

@RazvanN7 RazvanN7 merged commit e319a93 into dlang:master Apr 12, 2022
@dkorpel dkorpel deleted the c-assert-loc branch April 12, 2022 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants