File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -16843,8 +16843,12 @@ Expression toBoolean(Expression exp, Scope* sc)
16843
16843
if (!t.isBoolean())
16844
16844
{
16845
16845
if (tb != Type.terror)
16846
+ {
16846
16847
error(exp.loc, "expression `%s` of type `%s` does not have a boolean value",
16847
16848
exp.toChars(), t.toChars());
16849
+ if (auto ts = tb.isTypeStruct())
16850
+ errorSupplemental(ts.sym.loc, "perhaps add Cast Operator Overloading with `bool opCast(T : bool)() => ...`");
16851
+ }
16848
16852
return ErrorExp.get();
16849
16853
}
16850
16854
return e;
Original file line number Diff line number Diff line change 1
1
/*
2
2
TEST_OUTPUT:
3
3
---
4
- fail_compilation/diag13320.d(14): Error: operator `++` not supported for `f` of type `Foo`
5
- fail_compilation/diag13320.d(9): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}`
4
+ fail_compilation/diag13320.d(20): Error: operator `++` not supported for `f` of type `Foo`
5
+ fail_compilation/diag13320.d(14): perhaps implement `auto opUnary(string op : "++")() {}` or `auto opOpAssign(string op : "+")(int) {}`
6
+ fail_compilation/diag13320.d(21): Error: expression `f` of type `Foo` does not have a boolean value
7
+ fail_compilation/diag13320.d(14): perhaps add Cast Operator Overloading with `bool opCast(T : bool)() => ...`
8
+ fail_compilation/diag13320.d(22): Error: expression `Foo()` of type `E` does not have a boolean value
9
+ fail_compilation/diag13320.d(14): perhaps add Cast Operator Overloading with `bool opCast(T : bool)() => ...`
6
10
---
7
11
*/
8
12
13
+
9
14
struct Foo {}
15
+ enum E : Foo { a = Foo .init }
10
16
11
17
void main ()
12
18
{
13
19
Foo f;
14
20
++ f;
21
+ if (f) {}
22
+ assert (E.a);
15
23
}
You can’t perform that action at this time.
0 commit comments