www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23800] New: -checkaction=context asserts on deprecated type

https://issues.dlang.org/show_bug.cgi?id=23800

          Issue ID: 23800
           Summary: -checkaction=context asserts on deprecated type
                    comparisons should not trigger deprecation messages
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schveiguy gmail.com

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.

--
Mar 22 2023