Skip to content

Fix deprecation warning: UDA extraction for overload sets#93

Merged
9il merged 1 commit into
libmir:masterfrom
Laeeth:fix-deprecation
Feb 23, 2026
Merged

Fix deprecation warning: UDA extraction for overload sets#93
9il merged 1 commit into
libmir:masterfrom
Laeeth:fix-deprecation

Conversation

@Laeeth

@Laeeth Laeeth commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Handle overloaded symbols in getUDAs/autoGetUDAs by using __traits(getOverloads) and flattening per-overload UDAs before filtering.

This avoids deprecated __traits(getAttributes) on overload sets and reduces the warning spam seen in builds against overloaded functions.

NB: heavily AI-assisted and I have not had time to study this carefully.

Handle overloaded symbols in getUDAs/autoGetUDAs by using __traits(getOverloads) and flattening per-overload UDAs before filtering.

This avoids deprecated __traits(getAttributes) on overload sets and reduces the warning spam seen in builds against overloaded functions.

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

Updates Mir’s compile-time UDA introspection helpers to avoid deprecated __traits(getAttributes) calls on overload sets by switching to __traits(getOverloads) and aggregating attributes across overloads before filtering.

Changes:

  • Update getUDAs(alias symbol, alias attribute) to detect overload sets via __traits(getOverloads) and collect UDAs per overload.
  • Update autoGetUDAs(alias symbol) with similar overload-set handling to return aggregated attributes.

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

Comment on lines +119 to +126
static if (__traits(compiles, __traits(getOverloads, symbol)))
{
alias overloads = __traits(getOverloads, symbol);
static if (overloads.length > 0)
{
alias getUDAsImpl(alias overload) = Filter!(isDesiredUDA!attribute, __traits(getAttributes, overload));
alias getUDAs = AliasSeq!(staticMap!(getUDAsImpl, overloads));
}

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

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

New behavior for overload sets is introduced here, but the file’s unittests don’t cover overloaded symbols (multiple overloads with/without the target UDA). Adding a dedicated unittest for an overloaded function name would help prevent regressions and confirm the intended aggregation semantics across overloads.

Copilot uses AI. Check for mistakes.
Comment on lines +119 to +133
static if (__traits(compiles, __traits(getOverloads, symbol)))
{
alias overloads = __traits(getOverloads, symbol);
static if (overloads.length > 0)
{
alias getUDAsImpl(alias overload) = Filter!(isDesiredUDA!attribute, __traits(getAttributes, overload));
alias getUDAs = AliasSeq!(staticMap!(getUDAsImpl, overloads));
}
else static if (__traits(compiles, __traits(getAttributes, symbol)))
{
alias getUDAs = Filter!(isDesiredUDA!attribute, __traits(getAttributes, symbol));
}
else
alias getUDAs = AliasSeq!();
}

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

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

The overload-handling logic in getUDAs largely duplicates the overload-handling logic added to autoGetUDAs below. Consider centralizing this by having getUDAs filter over a single helper that returns the flattened attributes (e.g., autoGetUDAs!symbol), so the overload detection rules stay consistent and future changes only need to be made once.

Copilot uses AI. Check for mistakes.
@9il 9il merged commit 4397b03 into libmir:master Feb 23, 2026
14 of 22 checks passed
@9il

9il commented Feb 23, 2026

Copy link
Copy Markdown
Member

Thank you, Laeeth.

mir-algorithm and mir-ion are tested with this commit on macOS/ldc 1.41.0.

Tagged as v1.7.4

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