Closed zerbina closed 3 months ago
/merge
Merge requested by: @saem
Contents after the first section break of the PR description has been removed and preserved below:
## Notes for Reviewers * a regression introduced by #1382 * the fix is simple, and restoring what previously worked makes sense even if `type T {.importc.} = distinct U` becomes an error
Summary
Marking a
distinct T
type as imported resulted in multiple C definitions forT
, ifT
is a non-numeric, non-pointer type. This is now fixed.Fixes https://github.com/nim-works/nimskull/issues/1417.
Details
When translating imported types,
mirtypes
always created a new type symbol for the imported type's underlying type. FortyAlias
andtyDistinct
types (or any other type kind in theSkip
set), this resulted in a duplicate of the underlying type symbol being created. Since MIR types are identified by ID, both look separate tocgen
, and thus a C definition is emitted for each.handleImportedTypes
now goes through the caching mechanism for the underlying type if its not the type marked with.importc
, fixing the issue.