Skip to content

Fix #22667: hdrgen: Skip using typedefIdent for basic types#22669

Open
IDONTUSEGH wants to merge 8 commits intodlang:masterfrom
IDONTUSEGH:patch-1
Open

Fix #22667: hdrgen: Skip using typedefIdent for basic types#22669
IDONTUSEGH wants to merge 8 commits intodlang:masterfrom
IDONTUSEGH:patch-1

Conversation

@IDONTUSEGH
Copy link
Contributor

When generating .di files from ImportC code, a typedef like typedef void _IO_lock_t; would cause all subsequent uses of void to incorrectly print as _IO_lock_t in function signatures.

Fixes #22667

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @IDONTUSEGH! 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

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

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

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the test case from the linked issue, otherwise looks great!

@IDONTUSEGH IDONTUSEGH changed the title hdrgen: Skip using typedefIdent for basic types Fix #22667: hdrgen: Skip using typedefIdent for basic types Mar 1, 2026
@IDONTUSEGH
Copy link
Contributor Author

IDONTUSEGH commented Mar 1, 2026

I now have doubt after the test failed with my initial change, skipping for void fixes my specific use case but is just a hack, the following will fail:

typedef int _IO_lock_t;
int mylib_hello(void);

This may be related: #20889

cc @dkorpel

Both my C & D are rusty, so I may be missing something obvious..

@IDONTUSEGH
Copy link
Contributor Author

Ok i figured it out, it was reusing the global shared basic type instances (Type.tvoid, Type.tint32, etc.) when creating typedefs.

When insertTypedefToTypedefTab() set typedefIdent on these types, it was directly mutating the shared instance, causing ALL subsequent uses of void or int to appear as the typedef name in the generated .di

@thewilsonator
Copy link
Contributor

Thanks for figuring this out.

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks great

@IDONTUSEGH IDONTUSEGH requested a review from ibuclaw as a code owner March 3, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImportC: generating .di turns void into _IO_lock_t

3 participants