Bug 18310 – __traits(isDisabled) returns true for non-function struct member annotated with @disable
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-26T22:49:23Z
Last change time
2018-02-26T14:25:30Z
Assigned to
No Owner
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2018-01-26T22:49:23Z
Code:
-------
struct S {
@disable string toString();
}
static assert(__traits(isDisabled, S.toString)); // OK
struct T {
@disable float toString;
}
static assert(__traits(isDisabled, T.toString)); // NG
-------
Expected behaviour: either annotating a non-function member with @disable should be rejected with a compile error, or __traits(isDisabled) should return true in that case.
Comment #1 by razvan.nitu1305 — 2018-02-26T14:25:30Z
Well, the spec is very clear on this one. If the symbol is a function and is marked with @disable then traits(isDisabled) will return true, otherwise it will return false. So either if the symbol is not a function declaration or if it's not marked @disable, traits(isDisabled) returns false. I don't see any problems here, since marking @disabled a non-function is a no-op, so it makes sense to return false in that case.
Closing as invalid.