April 03 [Issue 24479] New: [REG2.104] Error on getAttributes on getOverloads of templates | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24479 Issue ID: 24479 Summary: [REG2.104] Error on getAttributes on getOverloads of templates Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: johanengelen@weka.io Testcase, https://d.godbolt.org/z/cheqP1eof: ``` import std.meta : Filter; struct S { S opBinary(string op: "-")(S rhs) const pure nothrow @nogc { return rhs; } S opBinary(string op: "*")(S dur) const pure nothrow @nogc { return dur; } } private enum hasExternalUDA(alias A) = is(A == External) || is(typeof(A) == External); void foo() { static foreach (t; __traits(getOverloads, S, "opBinary", true)) { static assert( Filter!(hasExternalUDA, __traits(getAttributes, t)).length == 0 ); } static foreach (t; __traits(getOverloads, S, "opBinary", true)) static foreach(attr; __traits(getAttributes, t)) pragma(msg, attr); static assert(__traits(getOverloads, S, "opBinary", true).length == 2); alias A = __traits(getAttributes, __traits(getOverloads, S, "opBinary", true)[1]); } ``` Fails (deprecations are errors!) since dlang 2.104, with deprecations: ``` <source>(16): Deprecation: `__traits(getAttributes)` may only be used for individual functions, not overload sets such as: `opBinary` <source>(16): the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from <source>(20): Deprecation: `__traits(getAttributes)` may only be used for individual functions, not overload sets such as: `opBinary` <source>(20): the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from <source>(24): Deprecation: `__traits(getAttributes)` may only be used for individual functions, not overload sets such as: `opBinary` <source>(24): the result of `__traits(getOverloads)` may be used to select the desired function to extract attributes from ``` Loosely related to https://issues.dlang.org/show_bug.cgi?id=23966. I don't know a workaround, because iterating with explicit indexing as suggested in 23966 also does not work (last line of testcase). -- |
Copyright © 1999-2021 by the D Language Foundation