| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S | ||
| { | ||
| ref S opAssign(S rhs) return | ||
| { | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| void test() | ||
| { | ||
| S a, b; | ||
| a = b; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S | ||
| { | ||
| ref S opOpAssign(string op)(S rhs) return | ||
| { | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| void test() | ||
| { | ||
| S a, b; | ||
| a += b; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S | ||
| { | ||
| ref S opUnary(string op)() return | ||
| { | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| void test() | ||
| { | ||
| S s; | ||
| ++s; | ||
| --s; | ||
| s++; | ||
| s--; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S {} | ||
|
|
||
| S fun() { return S(); } | ||
|
|
||
| void test() | ||
| { | ||
| cast(void) fun(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /+ | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/must_use.d(15): Error: ignored value of `@mustuse` type `must_use.S`; prepend a `cast(void)` if intentional | ||
| --- | ||
| +/ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S {} | ||
|
|
||
| S fun() { return S(); } | ||
|
|
||
| void test() | ||
| { | ||
| fun(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /+ | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/must_use_comma.d(16): Error: ignored value of `@mustuse` type `must_use_comma.S`; prepend a `cast(void)` if intentional | ||
| --- | ||
| +/ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S {} | ||
|
|
||
| S fun() { return S(); } | ||
| void sideEffect() {} | ||
|
|
||
| void test() | ||
| { | ||
| (fun(), sideEffect()); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /+ | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/must_use_opunary.d(20): Error: ignored value of `@mustuse` type `must_use_opunary.S`; prepend a `cast(void)` if intentional | ||
| --- | ||
| +/ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S | ||
| { | ||
| ref S opUnary(string op)() return | ||
| { | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
| void test() | ||
| { | ||
| S s; | ||
| -s; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /+ | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/must_use_reserved.d(14): Error: `@mustuse` on `class` types is reserved for future use | ||
| fail_compilation/must_use_reserved.d(15): Error: `@mustuse` on `interface` types is reserved for future use | ||
| fail_compilation/must_use_reserved.d(16): Error: `@mustuse` on `enum` types is reserved for future use | ||
| fail_compilation/must_use_reserved.d(17): Error: `@mustuse` on functions is reserved for future use | ||
| fail_compilation/must_use_reserved.d(19): Error: `@mustuse` on `class` types is reserved for future use | ||
| fail_compilation/must_use_reserved.d(20): Error: template instance `must_use_reserved.CT!int` error instantiating | ||
| --- | ||
| +/ | ||
| import core.attribute; | ||
|
|
||
| @mustuse class C {} | ||
| @mustuse interface I {} | ||
| @mustuse enum E { x } | ||
| @mustuse int fun() { return 0; } | ||
|
|
||
| @mustuse class CT(T) {} | ||
| alias _ = CT!int; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /+ | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/must_use_template.d(15): Error: ignored value of `@mustuse` type `must_use_template.S!int`; prepend a `cast(void)` if intentional | ||
| --- | ||
| +/ | ||
| import core.attribute; | ||
|
|
||
| @mustuse struct S(T) {} | ||
|
|
||
| S!int fun() { return S!int(); } | ||
|
|
||
| void test() | ||
| { | ||
| fun(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /+ | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/must_use_union.d(15): Error: ignored value of `@mustuse` type `must_use_union.U`; prepend a `cast(void)` if intentional | ||
| --- | ||
| +/ | ||
| import core.attribute; | ||
|
|
||
| @mustuse union U {} | ||
|
|
||
| U fun() { return U(); } | ||
|
|
||
| void test() | ||
| { | ||
| fun(); | ||
| } |