Skip to content

Fix incorrect spelling collision for struct typedef#297

Open
davispuh wants to merge 2 commits into
jacob-carlborg:masterfrom
davispuh:collision
Open

Fix incorrect spelling collision for struct typedef#297
davispuh wants to merge 2 commits into
jacob-carlborg:masterfrom
davispuh:collision

Conversation

@davispuh

Copy link
Copy Markdown

Consider a case where we have 2 files:
first.h

typedef struct {
  int a;
} B;

And
second.h

#include "first.h";

typedef B C;

Then currently trying to convert second.h we get warning:

$ dstep second.h
first.h:2:9: warning: a type renamed to 'B_' due to the collision with the symbol declared in first.h:4:3

This is not correct, because typedef B C means C is alias to B and it's not a collision.
This PR fixes this issue.

Copilot AI review requested due to automatic review settings March 18, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a false-positive spelling collision warning when a struct’s translated name matches a typedef symbol that actually aliases the same underlying struct (common when translating headers that include other headers).

Changes:

  • Adjusts collision detection in Context.translateTagSpelling to ignore collisions when the “colliding” symbol resolves to the same underlying cursor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread dstep/translator/Context.d Outdated
Comment thread dstep/translator/Context.d
@jacob-carlborg

Copy link
Copy Markdown
Owner

I think the code review from Copilot is reasonable.

davispuh added 2 commits June 23, 2026 22:29
Moved from IncludeGraphTests.d
This fixes case when we have 2 files:
```c
typedef struct {
  int a;
} B;
```
And
```c
 #include "first.h";

typedef B C;
```
@davispuh

Copy link
Copy Markdown
Author

Improved PR and added tests.

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.

3 participants