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 issue24534 : goto can skip declarations in labeled statements without error #16510

Merged
merged 2 commits into from
May 21, 2024

Conversation

benjones
Copy link
Contributor

Seems like a hacky fix to me since it doesn't seem like a label statement should be creating a new scope at all. I didn't look at what analysis the ctorflow call is doing, but I assume that's the reason it was like this?

Thoughts?

@dlang-bot
Copy link
Contributor

dlang-bot commented May 17, 2024

Thanks for your pull request and interest in making D better, @benjones! 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
24534 normal Having a label on a declaration makes it possible to skip it with goto

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#16510"

@benjones
Copy link
Contributor Author

Tests failing because of the issue in the backend which revealed the bug:

-----------------------------------------------------------
src/dmd/backend/cod1.d(1178): Error: `goto` skips declaration of variable `dmd.backend.cod1.getlvalue.idxregs`
src/dmd/backend/cod1.d(1185):        declared here

I'll try to fix that in another PR (declaration is in the middle of an 800 line function, so will require a bit of untangling)

@rikkimax
Copy link
Contributor

Doesn't look like a bug to me for PR or for the backend code.

The PR is doing exactly what I would expect it to do, error on code that was written with a C style (with multiple labels).

@Herringway
Copy link
Contributor

Doesn't look like a bug to me for PR or for the backend code.

The PR is doing exactly what I would expect it to do, error on code that was written with a C style (with multiple labels).

That's the bug... The compiler should not be relying on illegal D code.

@benjones benjones force-pushed the fix24534 branch 2 times, most recently from 8e5e85a to ea78c5b Compare May 20, 2024 18:38
@benjones
Copy link
Contributor Author

Blocked by a phobos issue: dlang/phobos#9003

@dlang-bot dlang-bot merged commit e4eae59 into dlang:master May 21, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants