Bug 23966 – [REG2.102] Cannot use traits(getAttributes) with overloaded template

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-04T19:30:47Z
Last change time
2023-07-15T15:30:05Z
Keywords
industry, pull, rejects-valid
Assigned to
No Owner
Creator
johanengelen

Comments

Comment #0 by johanengelen — 2023-06-04T19:30:47Z
Testcase: ``` module test; @("gigi") void fun() {} @("mimi") void fun(int) {} void fun()(int, ulong) {} void main() { static foreach (t; __traits(getOverloads, test, "fun")) static foreach(attr; __traits(getAttributes, t)) pragma(msg, attr); } ``` This no longer works with dlang 2.102, even though the release notes say that this is correct code. https://dlang.org/changelog/2.102.0.html#dmd.deprecate-getAttributes-overloadSet It errors on the fun()(...) template.
Comment #1 by destructionator — 2023-06-08T16:14:31Z
this also affected me in the jsvar.d internals. i worked around by calling getOverloads again inside the getOverloads loop. foreach(idx, _ignored; __traits(getOverloads)) __traits(getAttributes, __traits(getOverloads)[idx]) that kind of thing.
Comment #2 by razvan.nitu1305 — 2023-06-13T13:57:23Z
This is not a problem with the deprecation of __traits(getAttributes), but rather a problem of traits(getOverloads). This was simply exposed by the deprecation. If you use __traits(getLocation) instead of getAttributes, you will get the same behavior (except that an error is issued, not a deprecation): module test; @("gigi") void fun() {} @("mimi") void fun(int) {} @("didi") void fun()(int, ulong) {} void main() { //pragma(msg, __traits(getAttributes, fun)); pragma(msg, __traits(getOverloads, test, "fun")); static foreach (t; __traits(getOverloads, test, "fun")) pragma(msg, __traits(getLocation, t)); }
Comment #3 by razvan.nitu1305 — 2023-06-13T13:59:27Z
(In reply to RazvanN from comment #2) > This is not a problem with the deprecation of __traits(getAttributes), but > rather a problem of traits(getOverloads). This was simply exposed by the > deprecation. If you use __traits(getLocation) instead of getAttributes, you > will get the same behavior (except that an error is issued, not a > deprecation): > > module test; > > @("gigi") > void fun() {} > @("mimi") > void fun(int) {} > @("didi") > void fun()(int, ulong) {} > > void main() > { > //pragma(msg, __traits(getAttributes, fun)); > pragma(msg, __traits(getOverloads, test, "fun")); > static foreach (t; __traits(getOverloads, test, "fun")) > pragma(msg, __traits(getLocation, t)); > > } Updated snippet, without comments and extra things: module test; @("gigi") void fun() {} @("mimi") void fun(int) {} @("didi") void fun()(int, ulong) {} void main() { static foreach (t; __traits(getOverloads, test, "fun")) pragma(msg, __traits(getLocation, t)); }
Comment #4 by dlang-bot — 2023-06-27T10:07:13Z
@RazvanN7 created dlang/dmd pull request #15353 "Fix Issue 23966 - [REG2.102] Cannot use traits(getAttributes) with overloaded template" fixing this issue: - Fix Issue 23966 - [REG2.102] Cannot use traits(getAttributes) with overloaded template https://github.com/dlang/dmd/pull/15353
Comment #5 by dlang-bot — 2023-07-04T08:12:21Z
dlang/dmd pull request #15353 "Fix Issue 23966 - [REG2.102] Cannot use traits(getAttributes) with overloaded template" was merged into stable: - bf2c04df822eee078ec0debb151c09d794f709c9 by RazvanN7: Fix Issue 23966 - [REG2.102] Cannot use traits(getAttributes) with overloaded template https://github.com/dlang/dmd/pull/15353
Comment #6 by dlang-bot — 2023-07-15T15:30:05Z
dlang/dmd pull request #15417 "merge stable" was merged into master: - bb88be3bb1cb3c483bb35113c353b7c087ca6e97 by Razvan Nitu: Fix Issue 23966 - [REG2.102] Cannot use traits(getAttributes) with overloaded template (#15353) https://github.com/dlang/dmd/pull/15417