mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Fix 23236 - can't initialize a @mustuse member in constructor (#14303)
This commit is contained in:
parent
a0faedfa9f
commit
5da25c92c8
2 changed files with 17 additions and 1 deletions
|
@ -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())
|
||||
{
|
||||
|
|
16
compiler/test/compilable/must_use_initialize.d
Normal file
16
compiler/test/compilable/must_use_initialize.d
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue