[Issue 23236] New: can't initialize a @mustuse member in constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 10 14:30:17 UTC 2022


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

          Issue ID: 23236
           Summary: can't initialize a @mustuse member in constructor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

This should compile:
```
import core.attribute;

@mustuse struct MyError { }

struct S
{
    MyError lastError;

    this(int x) 
    {
        this.lastError = MyError(); // Error: ignored value of `@mustuse` type
`onlineapp.MyError`; prepend a `cast(void)` if intentional

    }
}
```
Assignment seems to work, but initialization is not considered ignoring the
value.

--


More information about the Digitalmars-d-bugs mailing list