Skip to content

feat(d): Use nominal typing - #1802

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
QuantumSegfault:dlang-use-nominal-types
Dec 3, 2026
Merged

alexcrichton merged 1 commit into
bytecodealliance:mainfrom
QuantumSegfault:dlang-use-nominal-types

Conversation

@QuantumSegfault

Copy link
Copy Markdown
Contributor

Fixes the issue introduced in #1800

Eliminates common.d for interfaces, opting into the uses_nominal_type_ids behavior of cloning ALL types of an exported interface.

@QuantumSegfault

Copy link
Copy Markdown
Contributor Author

@alexcrichton

I'm not particularly happy with duplicating types for import vs export when they are otherwise identical (no nested resources, etc. to make them distinct per direction)...

However it is what every other generator does, and things break without it, so I'm just making D fall in line.

The other option is to just patch the common sections emitted in finish to only ever be emitted once, and assume it is always identical (would be a much simpler patch). But that fights the concept of "nominal typing" being introduced. May cause other problems down the road.

@alexcrichton

Copy link
Copy Markdown
Member

One thing you might be interested to look into is the collect_equal_types method which Rust uses behind a --merge-structurally-equal-types flag which I believe is more-or-less what you want here. That hasn't been mapped into other generators yet and it's just Rust using that, but I believe it's targeted at the exact feature you want (sharing types more aggressively)

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the meantime though lgtm, thanks!

@alexcrichton
alexcrichton added this pull request to the merge queue Dec 3, 2026
Merged via the queue into bytecodealliance:main with commit c6372f8 Dec 3, 2026
28 checks passed
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.

2 participants