D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20389 - __traits(isDisabled) with invalid template function
Summary: __traits(isDisabled) with invalid template function
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-13 17:24 UTC by John Hall
Modified: 2024-12-13 19:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Hall 2019-11-13 17:24:41 UTC
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)));
}
Comment 1 John Hall 2019-11-13 18:10:52 UTC
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.
Comment 2 dlangBugzillaToGithub 2024-12-13 19:06:11 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19640

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB