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

Issue 18314 - std.traits.getSymbolsByUDA only considers the first sym… #6085

Merged
merged 1 commit into from Feb 1, 2018

Conversation

Biotronic
Copy link
Contributor

…bol of an overload set

This change expands overload sets such that each overload is considered separately.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @Biotronic! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Auto-close Bugzilla Description
18314 std.traits.getSymbolsByUDA only considers the first symbol of an overload set

Copy link
Member

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

Good job 👍
I especially like the bit that it's now without mixins :)

std/traits.d Outdated
@@ -7856,6 +7833,49 @@ template getSymbolsByUDA(alias symbol, alias attribute)
alias getSymbolsByUDA = membersWithUDA;
}

template getSymbolsByUDAImpl(alias symbol, alias attribute, names...)
Copy link
Member

Choose a reason for hiding this comment

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

private?

@wilzbach
Copy link
Member

(The Jenkins + CircleCI failures are unrelated)

@Biotronic
Copy link
Contributor Author

The thing I dislike about my implementation is getSymbolsByUDAImpl is recursive, and explicitly and verbosely does what the previous version did with Filter. Sadly, 5710 is still around, and I'm becoming more and tired of it.

@Dechcaudron
Copy link
Contributor

Dechcaudron commented Jan 28, 2018

Thanks for the PR @Biotronic. I was planning on fixing it myself, but you were way too fast 😄 (I reported it like 24 hours ago)

std/traits.d Outdated
void foo(int a);
}

assert(getSymbolsByUDA!(A, lal).length == 2);
Copy link

Choose a reason for hiding this comment

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

static assert(... twice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. This should be done at CT.

std/traits.d Outdated

struct A
{
@lal
Copy link

Choose a reason for hiding this comment

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

insert this declaration first

@lal
void foo()(string){}

update the assertions accordingly, and have fun.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of style, could we use @Attr1 and @Attr2 instead of @lol and @lal? I know I originally used those in my issue report, but it definitely was not my intention that such funny names ended up in the source code.

Copy link
Contributor Author

@Biotronic Biotronic Feb 1, 2018

Choose a reason for hiding this comment

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

This bug has already been filed in BugZilla. Looks to be by you:
https://issues.dlang.org/show_bug.cgi?id=16206

It's not the mandate of this PR to fix bugs in DMD. That said, mentioning the bug in the test is probably a good idea.

Copy link

Choose a reason for hiding this comment

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

Indeed. I planned to put the link to the issue after a possible "wtf" reaction from your part. But things didn't happen as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WTF?!
Here. Feeling better now?

Copy link
Member

Choose a reason for hiding this comment

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

I originally used those in my issue report, but it definitely was not my intention that such funny names ended up in the source code.

If you already come with the style, it should be attr1 and attr2 - https://dlang.org/dstyle.html#naming_udas

But meh, I don't have a preference between these two. It's quite typical for contributors to put the code from the issue 1:1 into Phobos. Also it doesn't end up in the user documentation.
And if you disagree, this can always be improved. It shouldn't block this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed. I planned to put the link to the issue after a possible "wtf" reaction from your part. But things didn't happen as expected.

Please refrain from wasting valuable time of other contributors in the future.
A simple comment:

I just bumped into a similar issue. See XYZ

would have saved all parties time...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but we'd have less fun that way.

@Biotronic
Copy link
Contributor Author

And apparently I broke the auto-merge when I addressed the stuff that was mentioned above.

@wilzbach
Copy link
Member

wilzbach commented Feb 1, 2018

And apparently I broke the auto-merge when I addressed the stuff that was mentioned above.

Yes, it's not a bug it's a security feature.

image

@dlang-bot dlang-bot merged commit 2a6df1f into dlang:master Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants