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

__traits(isDisabled) with invalid template function #19640

Open
dlangBugzillaToGithub opened this issue Nov 13, 2019 · 1 comment
Open

__traits(isDisabled) with invalid template function #19640

dlangBugzillaToGithub opened this issue Nov 13, 2019 · 1 comment
Labels

Comments

@dlangBugzillaToGithub
Copy link

John Hall reported this on 2019-11-13T17:24:41Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=20389

Description

If you @disable a templated function that is not valid and then try to call __traits(isDisabled) on it with the template instantiated with something other than a type, then you will get a message that the template instance does not match the declaration. However, it does not tell you why. For instance, in the code below, T should also be part of the template, but you can only find that out if you actually call foo. 

@disable T[] foo(U)(T[] x, T rhs)
{
    return x ~ rhs;
}

unittest {
    static assert(__traits(isDisabled, foo!"~"));
}

I would reiterate that this seems to be related to using something other than a type in the instantiation. If I try the code below, then it tells me that T is an undefined identifier.

unittest {
    static assert(__traits(isDisabled, foo!(int)));
}
@dlangBugzillaToGithub
Copy link
Author

john.michael.hall commented on 2019-11-13T18:10:52Z

It seems that this is related to not having a module defined...

When I add something like
module A;
to the top and then 
static assert(__traits(isDisabled, A.foo));
compiles without error when U is there and if U is removed then it gives the error that T is not defined.

@thewilsonator thewilsonator added Feature:traits Relating to __traits and removed OS:Windows Arch:x86 Issues specific to x86 P4 labels Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants