Bug 23970 – [REG2.097.0] Deprecation not emitted when selectively importing deprecated function
Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-05T07:54:15Z
Last change time
2023-06-13T09:58:41Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2023-06-05T07:54:15Z
This isn't so bad because a deprecation is still emitted when the function is used.
But still, it should probably be emitted on a selective import too.
//////////////// a.d ////////////////
deprecated int var;
deprecated void fun() {}
/////////////// test.d //////////////
// import a : var; // OK, deprecation
import a : fun; // No deprecation?
/////////////////////////////////////
Introduced in https://github.com/dlang/dmd/pull/12442
Comment #1 by razvan.nitu1305 — 2023-06-13T08:06:16Z
I think this behavior is fine. Note that `fun` may also have a non-deprecated overload, in which case you are selectively importing an overload set. In that case, it would be wrong to output a deprecation. In this case, checking all overloads for a non-deprecated one seems like an overkill. From that point of view, having an overload set of just one overload means that we don't have to output the deprecation. Of course, a special case can be added: for overload sets with just one overload check if it is deprecated, but this seems overkill to me; the deprecation is going to be issued at the call site any way.
Comment #2 by dlang-bugzilla — 2023-06-13T09:10:28Z
That sounds fine to me. I just want to note that maybe deprecation should be a property that is tracked for overload sets; then, maintaining that property on the overload set, and checking if all of the functions in the overload set are deprecated, become a O(1) operation.
Comment #3 by razvan.nitu1305 — 2023-06-13T09:58:41Z
Yes, it could be implemented, however it will add cyclomatic complexity for no apparent benefit since the deprecation is issued on the call site anyway.