-
-
Notifications
You must be signed in to change notification settings - Fork 610
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 23148, 21723: Generate invariant id on the basis of location rather than counter. #14176
Fix issue 23148, 21723: Generate invariant id on the basis of location rather than counter. #14176
Conversation
|
Thanks for your pull request and interest in making D better, @FeepingCreature! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
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
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + dmd#14176" |
|
Please include the test case from the bug report, removing the use of the standard library. |
|
Will add the testcase, soon as I figure out what's going on with the failures. |
2c6d9e6 to
384d5a2
Compare
|
Should be good now, tests pass locally. Test case added. Note: There is nothing using the standard library in the bug report. It's reduced from std.sumtype, that's why it looks like that, but it's freestanding. |
|
Since this also fixes 21723, I'll add a testcase for that too. |
…n rather than counter. This makes __invariant more resilient to template order issues.
384d5a2 to
4e01c6a
Compare
|
Are locations unique though? I thought this wasn't done because in |
|
Ah shit, I noticed templates but I forgot about |
|
Hm, I'm actually having a hard time constructing a test case of a If it's nested in a function, struct, class or template, even if it has the same name, it's mangled with that type and can disambiguate on that basis. edit: Hang on, isn't that impossible? If the structs have the same mangling, every function in them should collide, not just invariant. The only reason we need the line/column number, or counter, is that we have structs with multiple invariants. We could just count from the start of the struct and get the same effect. So maybe static foreach in the struct would collide? |
|
Oh wait, looking at Identifier.d, it has another counter that's site specific. So we're good. Ie. with invariant in a foreach loop, you get _L5_C3_1, _L5_C3_2, etc. Man DMD really likes global variables though. |
|
Ah, but that global counter causes another undefined-reference bug that I'll probably have to dustmite. The fun never stops with global variables!!! 🤮 |
This makes it more resilient to template order issues.
Thanks Basile B. for the proposal!
Let's see what breaks...