Bug 23800 – -checkaction=context asserts on deprecated type comparisons should not trigger deprecation messages

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-03-22T17:03:32Z
Last change time
2024-12-13T19:27:57Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: dmd#18159 →

Comments

Comment #0 by schveiguy — 2023-03-22T17:03:32Z
Consider a type that I want to deprecate: ```d struct T { int x; } unittest { assert(T(1) == T(1)); } ``` If I deprecate T, then I also must deprecate the unittest, or else I get deprecation messages (as expected). However, if I then use the `-checkaction=context` command line parameter, there are now deprecation messages because the compiler is trying to format the string using the deprecated type: ``` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(65): Deprecation: struct `onlineapp.T` is deprecated onlineapp.d(7): instantiated from here: `_d_assert_fail!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(65): Deprecation: struct `onlineapp.T` is deprecated onlineapp.d(7): instantiated from here: `_d_assert_fail!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(522): Deprecation: struct `onlineapp.T` is deprecated /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(75): instantiated from here: `miniFormatFakeAttributes!(T)` onlineapp.d(7): instantiated from here: `_d_assert_fail!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(176): Deprecation: struct `onlineapp.T` is deprecated /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(524): instantiated from here: `miniFormat!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(75): instantiated from here: `miniFormatFakeAttributes!(T)` onlineapp.d(7): instantiated from here: `_d_assert_fail!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(425): Deprecation: struct `onlineapp.T` is deprecated /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(404): instantiated from here: `formatMembers!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(524): instantiated from here: `miniFormat!(T)` /dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/dassert.d(75): instantiated from here: `miniFormatFakeAttributes!(T)` onlineapp.d(7): instantiated from here: `_d_assert_fail!(T)` ``` I propose that checkaction=context does not apply for comparisons involving deprecated types, or that it doesn't apply inside deprecated functions/unittests. The workaround is to change the assert to `assert((T(1) == T(1)) == true);` But this is quite tedious to enact. I'd rather just have the compiler do it for me.
Comment #1 by robert.schadek — 2024-12-13T19:27:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18159 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB