Fix 23236 - can't initialize a @mustuse member in constructor (#14303)

This commit is contained in:
Dennis 2022-07-14 17:32:43 +02:00 committed by GitHub
parent a0faedfa9f
commit 5da25c92c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -98,7 +98,7 @@ void checkMustUseReserved(Dsymbol sym)
*/
private bool isAssignment(Expression e)
{
if (e.isAssignExp || e.isBinAssignExp)
if (e.isAssignExp || e.isBinAssignExp || e.isConstructExp || e.isBlitExp)
return true;
if (auto ce = e.isCallExp())
{

View file

@ -0,0 +1,16 @@
// https://issues.dlang.org/show_bug.cgi?id=23236
// can't initialize a @mustuse member in constructor
import core.attribute;
@mustuse struct MyError { }
struct S
{
MyError lastError;
this(int x)
{
this.lastError = MyError();
}
}