-
-
Notifications
You must be signed in to change notification settings - Fork 619
/
Copy pathdmd.error-messages.dd
123 lines (99 loc) · 3.48 KB
/
dmd.error-messages.dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Many error messages have changed
Some changes have been made without being associated to a reported issue:
Error messages for `@safe` violations now consistently mention they are related to `@safe` functions (or default functions with `-preview=safer`).
In general, function attributes that failed to infer have a more compact error message:
Before:
$(CONSOLE
app.d(8): Error: function `attributediagnostic_nothrow.gc1` is not `nothrow`
app.d(2): which wasn't inferred `nothrow` because of:
app.d(2): `object.Exception` is thrown but not caught
)
After:
$(CONSOLE
app.d(8): Error: function `attributediagnostic_nothrow.gc1` is not `nothrow`
app.d(2): and `object.Exception` being thrown but not caught makes it fail to infer `nothrow`
)
Function literals are now referred to by their (truncated) function body, instead of the internal `__lambda` name.
---
/*
BEFORE:
../test/test_.d(3): Error: function literal `__lambda1()` is not callable using argument types `(int)`
(() => 42)(1);
^
AFTER:
../test/test_.d(3): Error: function literal `() => 42` is not callable using argument types `(int)`
(() => 42)(1);
^
*/
---
Match levels are now mentioned on ambiguous overloads: [#20637](https://github.com/dlang/dmd/pull/20637)
Before:
$(CONSOLE
Error: `app.bar` called with argument types `(string)` matches both:
)
After:
$(CONSOLE
Error: `app.bar` called with argument types `(string)` matches multiple overloads after implicit conversions:
)
Error messages related to operator overloading have been improved.
When the related template functions (`opUnary`, `opBinary`, `opBinaryRight`, `opOpAssign`, `opIndex`, `opSlice`)
are missing, a suggestion to implement them is given.
When they do exist but fail to instantiate, the error from instantiation is shown.
There's no longer a need to manually e.g. rewrite `s + 1` to `s.opBinary!"+"(1)` to diagnose the error.
---
struct S {}
void main()
{
S s;
const x = s[3 .. "4"];
}
---
Before:
$(CONSOLE
app.d(6): Error: no `[]` operator overload for type `S`
)
After:
$(CONSOLE
app.d(6): Error: no `[3.."4"]` operator overload for type `S`
app.d(1): perhaps define `auto opSlice(int lower, string upper) {}` for `app.S`
)
---
struct Str {}
struct Number
{
int x;
int opBinary(string op : "+")(int rhs) => this.x + x;
}
void f(Str str, Number number)
{
const s = str ~ "hey";
const n = number + "oops";
}
---
Before:
$(CONSOLE
app.d(12): Error: incompatible types for `(str) ~ ("hey")`: `Str` and `string`
const s = str ~ "hey";
^
app.d(13): Error: incompatible types for `(number) + ("oops")`: `Number` and `string`
const n = number + "oops";
)
After:
$(CONSOLE
app.d(12): Error: operator `~` is not defined for type `Str`
const s = str ~ "hey";
^
app.d(2): perhaps overload the operator with `auto opBinary(string op : "~")(string rhs) {}`
struct Str {}
^
app.d(13): Error: function `test_.Number.opBinary!"+".opBinary(int rhs)` is not callable using argument types `(string)`
const n = number + "oops";
^
app.d(13): cannot pass argument `"oops"` of type `string` to parameter `int rhs`
app.d(7): `opBinary` defined here
int opBinary(string op : "+")(int rhs) => this.x + x;
^
)
Furthermore:
- D1 operator overloading functions (`opAdd`, `opDot`) are completely removed and no longer mentioned in error messages specifically.
- Class allocators (`auto new() {}`) are not only a semantic error, but no longer parse.