Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 23966 - [REG2.102] Cannot use traits(getAttributes) with overloaded template #15353

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

RazvanN7
Copy link
Contributor

FuncDeclaration.isUnique did not take into account template overloads. This caused some FuncAliasDeclarations (used by traits(getOverloads)) to be wrongfully substituted and therefore tripped the deprecation. I fixed the isUnique function to take into consideration templates, however, this affects the mangling of some functions (see commented test).

@dlang-bot
Copy link
Contributor

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

Auto-close Bugzilla Severity Description
23966 regression [REG2.102] Cannot use traits(getAttributes) with overloaded template

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 "stable + dmd#15353"

@@ -528,7 +528,7 @@ version (CppMangle_Itanium)
static assert(basic_ostream!(char, char_traits!char).food.mangleof == "_ZNSo4foodEv");
static assert(basic_iostream!(char, char_traits!char).fooe.mangleof == "_ZNSd4fooeEv");

static assert(func_18957_2.mangleof == `_Z12func_18957_2PSaIiE`);
//static assert(func_18957_2.mangleof == `_Z12func_18957_2PSaIiE`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

func_18957_2 is an overload set with a normal function and a function template. Up until now dmd just chose the function because of the bug in isUnique. I would argue that this should be an error. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps put this comment in the test, so it's clear why the assert is disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment was used as a discussion starter. I don't expect this PR will be merged with this test commented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One way to fix this without introducing any breaking changes is to add an optional bool parameter to isUnique which is set only when isUnique is called from semanticTiargs. That way, we can preserve the existing behavior with respect to the mangling of functions. Although, I still tend to argue that the way this patch deals with things is the more correct approach.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not terribly concerned with changing the name mangling. D libraries compiled with one version of DMD and linking with modules compiled with another version are a risky business regardless.

@RazvanN7 RazvanN7 added the Review:Industry Applies to PRs pertaining to industry applications of D label Jun 27, 2023
@@ -528,7 +528,7 @@ version (CppMangle_Itanium)
static assert(basic_ostream!(char, char_traits!char).food.mangleof == "_ZNSo4foodEv");
static assert(basic_iostream!(char, char_traits!char).fooe.mangleof == "_ZNSd4fooeEv");

static assert(func_18957_2.mangleof == `_Z12func_18957_2PSaIiE`);
//static assert(func_18957_2.mangleof == `_Z12func_18957_2PSaIiE`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps put this comment in the test, so it's clear why the assert is disabled

@WalterBright
Copy link
Member

@RazvanN7 can you please make a posting to the n.g. about this fix, so people who it was failing for can see it?

@RazvanN7 RazvanN7 merged commit bb88be3 into dlang:stable Jul 4, 2023
@ibuclaw ibuclaw mentioned this pull request Jul 15, 2023
kinke pushed a commit to symmetryinvestments/dmd that referenced this pull request Aug 2, 2023
kinke pushed a commit to symmetryinvestments/dmd that referenced this pull request Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review:Industry Applies to PRs pertaining to industry applications of D Severity:Bug Fix
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants