Skip to content

fix issue 17791 - add __traits(deprecated, symbol) #7178

Merged
MartinNowak merged 2 commits intodlang:masterfrom
dunkyp:master
Oct 5, 2017
Merged

fix issue 17791 - add __traits(deprecated, symbol) #7178
MartinNowak merged 2 commits intodlang:masterfrom
dunkyp:master

Conversation

@dunkyp
Copy link
Copy Markdown
Contributor

@dunkyp dunkyp commented Oct 3, 2017

No description provided.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request, @dunkyp! 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
17791 Add __traits(isDeprecated, ...)

@MartinNowak
Copy link
Copy Markdown
Member

Would it make sense to somehow make the deprecation message introspectable too?

@PetarKirov
Copy link
Copy Markdown
Member

We also need a way to obtain any compiler messages/errors, so I would prefer to leave this PR as it is and focus on a more general solution, like something along the lines of:

struct S
{
    auto opDispatch(string member, T...)(T args)
    {
        static if (args.length % 42 < 13)
            static assert (0, "Solve the mystery!");

        //...
    }
}

enum string[] messages = __traits(captureStdErrOutput,
{
    S s;
    s.theAnswer(1, 2);
});

static assert (messages.canFind("Solve the mystery!"));

@MartinNowak MartinNowak merged commit 70d909e into dlang:master Oct 5, 2017
@wilzbach
Copy link
Copy Markdown
Contributor

wilzbach commented Oct 5, 2017

This should have been accompanied

@dunkyp would you be so kind to submit the spec & changelog PR? Thanks!

@wilzbach
Copy link
Copy Markdown
Contributor

wilzbach commented Oct 5, 2017

Btw has anyone considered the possibility to add this to the existing getFunctionAttributes trait?
After all, there's also no way to check for @future atm.

@PetarKirov
Copy link
Copy Markdown
Member

I also considered getFunctionAttributes, but the deprecated attribute can be applied to more kinds of symbols than just functions. If the trait was called getAttributes or something like that, then yes it would have been a better place add this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants