www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22300] New: [REG 2.098-rc.2] `-checkaction=context` of a

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

          Issue ID: 22300
           Summary: [REG 2.098-rc.2] `-checkaction=context` of a `shared`
                    type with an `opCast` fails to compile
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

```
struct Fail
{
    int value;

     safe pure nothrow  nogc:
    bool opCast () shared const scope { return true; }
}

void main ()
{
    assert(shared(Fail).init);
}
```

Compiled with `~/dlang/ldc-36198b36/bin/ldc2 -checkaction=context -run wat.d`:
```
/Users/geod24/dlang/ldc-36198b36/bin/../import/core/internal/dassert.d(194):
Error: cannot implicitly convert expression `v.opCast()` of type `bool` to
`const(Fail)`
/Users/geod24/dlang/ldc-36198b36/bin/../import/core/internal/dassert.d(527):
Error: template instance `core.internal.dassert.miniFormat!(shared(Fail))`
error instantiating
/Users/geod24/dlang/ldc-36198b36/bin/../import/core/internal/dassert.d(44):    
   instantiated from here: `miniFormatFakeAttributes!(shared(Fail))`
wat.d(11):        instantiated from here: `_d_assert_fail!(shared(Fail))`
```

Worked fine in v2.097.0. Affects vibe-core so it's pretty serious.

--
Sep 13