Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0074a1f
fix #21399 - error message for multiple character constants
Iskaban10 Dec 16, 2025
abe147f
fix #21399 updated
Iskaban10 Dec 16, 2025
465079c
fail4544.d updated
Iskaban10 Dec 17, 2025
d44d7a7
changed fail4544.d
Iskaban10 Dec 17, 2025
aabadb3
Merge branch 'dlang:master' into improve-error-msg
Iskaban10 Dec 17, 2025
f28104c
fix #21381 for correct location in error message
Iskaban10 Dec 23, 2025
9953faa
Merge branch 'improve-error-msg' of https://github.com/Iskaban10/dmd …
Iskaban10 Dec 23, 2025
5c43e6e
Updated
Iskaban10 Dec 23, 2025
a705fa9
Better Template error messages
Iskaban10 Dec 25, 2025
39df2e2
Updated
Iskaban10 Dec 25, 2025
790aa66
Updated
Iskaban10 Dec 25, 2025
0bab93e
Updated
Iskaban10 Dec 25, 2025
ebb014e
Updated
Iskaban10 Dec 25, 2025
73de5a6
Removed fprintf
Iskaban10 Dec 26, 2025
3c9b4ad
Added message()
Iskaban10 Dec 26, 2025
7700710
Function is @safe and returns const(char)*
Iskaban10 Dec 27, 2025
3457709
buf.ptr replaced with &buf[0]
Iskaban10 Dec 27, 2025
9a3b0b5
Merge branch 'dlang:master' into improve-error-msg
Iskaban10 Dec 31, 2025
70f01fb
Updated fail_compilation tests
Iskaban10 Dec 31, 2025
2dc7f0f
Merge branch 'improve-error-msg' of https://github.com/Iskaban10/dmd …
Iskaban10 Dec 31, 2025
b0a9eaf
Changed \ t /
Iskaban10 Dec 31, 2025
500c1f6
Updated tests
Iskaban10 Jan 1, 2026
f8189de
Updated tests
Iskaban10 Jan 1, 2026
4b8ed8f
Updated tests
Iskaban10 Jan 1, 2026
00af04b
Updated tests
Iskaban10 Jan 1, 2026
64a865a
Updated tests
Iskaban10 Jan 1, 2026
70ea306
Updated tests
Iskaban10 Jan 1, 2026
2d075f0
Updated test
Iskaban10 Jan 1, 2026
7ed3eea
Removed Whitespaces
Iskaban10 Jan 1, 2026
6db2b04
Removed Whitespaces
Iskaban10 Jan 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions compiler/src/dmd/funcsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2068,16 +2068,48 @@ private void printCandidates(Decl)(Loc loc, Decl declaration, bool showDeprecate
bool child; // true if inside an eponymous template
const(char)* errorPrefix() @safe
{
static char[128] buf;
size_t pos = 0;
if (child)
return " - Containing: ";

// align with blank spaces after first message
enum plural = "Candidates are: ";
enum spaces = " ";
if (printed)
return spaces;

return (count == 1) ? "Candidate is: " : plural;
{
enum prefix = "Candidate "; // Prefix of the message to be displayed
foreach(i; 0 .. prefix.length)
{
buf[pos++] = prefix[i];
}
static char[64] tmp; // Buffer to store digits of the number
int idx = 0 ; // index for tmp buffer
int copy = printed + 1; // Stores the candidate number that will be displayed
// store the reversed number
while(copy)
{
tmp[idx++] = cast(char)('0' + copy%10);
copy /= 10;
}
tmp[idx] = '\0';
// in place reversal of digits
for(int end = idx-1 ; end>=0 ;end--)
{
buf[pos++] = tmp[end];
}
// Suffix of the message
enum suffix = " is: ";
foreach(i;0 .. suffix.length)
{
buf[pos++] = suffix[i];
}
buf[pos] = '\0';
return &buf[0];
}
if(count == 1)
return "Candidate is: ";
else
{
return "Candidate 1 is: ";
}
}
bool matchSymbol(Dsymbol s, bool print)
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/b19717a.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
fail_compilation/b19717a.d(14): Error: forward reference to template `a`
fail_compilation/b19717a.d(14): Error: forward reference to template `a`
fail_compilation/b19717a.d(14): Error: none of the overloads of `a` are callable using argument types `()`
fail_compilation/b19717a.d(13): Candidates are: `b19717a.a(int b)`
fail_compilation/b19717a.d(14): `b19717a.a(int b = a)`
fail_compilation/b19717a.d(13): Candidate 1 is: `b19717a.a(int b)`
fail_compilation/b19717a.d(14): Candidate 2 is: `b19717a.a(int b = a)`
---
*/
module b19717a;
Expand Down
16 changes: 8 additions & 8 deletions compiler/test/fail_compilation/constraints_func3.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ EXTRA_FILES: imports/constraints.d
TEST_OUTPUT:
----
fail_compilation/constraints_func3.d(53): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int)`
fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)`
fail_compilation/imports/constraints.d(39): Candidate 1 is: `overload(T)(T v)`
with `T = int`
must satisfy the following constraint:
` N!T`
fail_compilation/imports/constraints.d(40): `overload(T)(T v)`
fail_compilation/imports/constraints.d(40): Candidate 2 is: `overload(T)(T v)`
with `T = int`
must satisfy the following constraint:
` !P!T`
fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)`
fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)`
fail_compilation/imports/constraints.d(41): Candidate 3 is: `overload(T)(T v1, T v2)`
fail_compilation/imports/constraints.d(42): Candidate 4 is: `overload(T, V)(T v1, V v2)`
fail_compilation/constraints_func3.d(54): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int, string)`
fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)`
fail_compilation/imports/constraints.d(40): `overload(T)(T v)`
fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)`
fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)`
fail_compilation/imports/constraints.d(39): Candidate 1 is: `overload(T)(T v)`
fail_compilation/imports/constraints.d(40): Candidate 2 is: `overload(T)(T v)`
fail_compilation/imports/constraints.d(41): Candidate 3 is: `overload(T)(T v1, T v2)`
fail_compilation/imports/constraints.d(42): Candidate 4 is: `overload(T, V)(T v1, V v2)`
with `T = int,
V = string`
must satisfy one of the following constraints:
Expand Down
16 changes: 8 additions & 8 deletions compiler/test/fail_compilation/constraints_func4.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ TEST_OUTPUT:
fail_compilation/constraints_func4.d(90): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int)`
overload(0);
^
fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)`
fail_compilation/imports/constraints.d(39): Candidate 1 is: `overload(T)(T v)`
with `T = int`
must satisfy the following constraint:
` N!T`
void overload(T)(T v) if (N!T);
^
fail_compilation/imports/constraints.d(40): `overload(T)(T v)`
fail_compilation/imports/constraints.d(40): Candidate 2 is: `overload(T)(T v)`
with `T = int`
must satisfy the following constraint:
` !P!T`
void overload(T)(T v) if (!P!T);
^
fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)`
fail_compilation/imports/constraints.d(41): Candidate 3 is: `overload(T)(T v1, T v2)`
void overload(T)(T v1, T v2) if (N!T);
^
fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)`
fail_compilation/imports/constraints.d(42): Candidate 4 is: `overload(T, V)(T v1, V v2)`
void overload(T, V)(T v1, V v2) if (N!T || N!V);
^
fail_compilation/constraints_func4.d(91): Error: none of the overloads of template `imports.constraints.overload` are callable using argument types `!()(int, string)`
overload(0, "");
^
fail_compilation/imports/constraints.d(39): Candidates are: `overload(T)(T v)`
fail_compilation/imports/constraints.d(39): Candidate 1 is: `overload(T)(T v)`
void overload(T)(T v) if (N!T);
^
fail_compilation/imports/constraints.d(40): `overload(T)(T v)`
fail_compilation/imports/constraints.d(40): Candidate 2 is: `overload(T)(T v)`
void overload(T)(T v) if (!P!T);
^
fail_compilation/imports/constraints.d(41): `overload(T)(T v1, T v2)`
fail_compilation/imports/constraints.d(41): Candidate 3 is: `overload(T)(T v1, T v2)`
void overload(T)(T v1, T v2) if (N!T);
^
fail_compilation/imports/constraints.d(42): `overload(T, V)(T v1, V v2)`
fail_compilation/imports/constraints.d(42): Candidate 4 is: `overload(T, V)(T v1, V v2)`
with `T = int,
V = string`
must satisfy one of the following constraints:
Expand Down
10 changes: 5 additions & 5 deletions compiler/test/fail_compilation/ctor_attr.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
TEST_OUTPUT:
---
fail_compilation/ctor_attr.d(26): Error: none of the overloads of `this` can construct a mutable object with argument types `(int)`
fail_compilation/ctor_attr.d(16): Candidates are: `ctor_attr.S.this(int x) const`
fail_compilation/ctor_attr.d(18): `ctor_attr.S.this(string x)`
fail_compilation/ctor_attr.d(17): `this()(int x) shared`
fail_compilation/ctor_attr.d(16): Candidate 1 is: `ctor_attr.S.this(int x) const`
fail_compilation/ctor_attr.d(18): Candidate 2 is: `ctor_attr.S.this(string x)`
fail_compilation/ctor_attr.d(17): Candidate 3 is: `this()(int x) shared`
fail_compilation/ctor_attr.d(28): Error: none of the overloads of `foo` are callable using a mutable object with argument types `(int)`
fail_compilation/ctor_attr.d(20): Candidates are: `ctor_attr.S.foo(int x) immutable`
fail_compilation/ctor_attr.d(21): `ctor_attr.S.foo(string x)`
fail_compilation/ctor_attr.d(20): Candidate 1 is: `ctor_attr.S.foo(int x) immutable`
fail_compilation/ctor_attr.d(21): Candidate 2 is: `ctor_attr.S.foo(string x)`
---
*/

Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/diag10415.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
TEST_OUTPUT:
---
fail_compilation/diag10415.d(36): Error: none of the overloads of `x` are callable using argument types `(int) const`
fail_compilation/diag10415.d(13): Candidates are: `diag10415.C.x() const`
fail_compilation/diag10415.d(18): `diag10415.C.x(int __param_0)`
fail_compilation/diag10415.d(13): Candidate 1 is: `diag10415.C.x() const`
fail_compilation/diag10415.d(18): Candidate 2 is: `diag10415.C.x(int __param_0)`
fail_compilation/diag10415.d(39): Error: d.x is not an lvalue
---
*/
Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/diag11078.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
TEST_OUTPUT:
---
fail_compilation/diag11078.d(19): Error: none of the overloads of `value` are callable using argument types `(double)`
fail_compilation/diag11078.d(12): Candidates are: `diag11078.S1.value()`
fail_compilation/diag11078.d(13): `diag11078.S1.value(int n)`
fail_compilation/diag11078.d(12): Candidate 1 is: `diag11078.S1.value()`
fail_compilation/diag11078.d(13): Candidate 2 is: `diag11078.S1.value(int n)`
---
*/

Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/diag14818.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
TEST_OUTPUT:
---
fail_compilation/diag14818.d(40): Error: none of the overloads of `func` are callable using argument types `(string)`
fail_compilation/diag14818.d(18): Candidates are: `diag14818.foo(int __param_0)`
fail_compilation/diag14818.d(19): `diag14818.bar(double __param_0)`
fail_compilation/diag14818.d(18): Candidate 1 is: `diag14818.foo(int __param_0)`
fail_compilation/diag14818.d(19): Candidate 2 is: `diag14818.bar(double __param_0)`
fail_compilation/diag14818.d(41): Error: template instance `diag14818.X!string` does not match any template declaration
fail_compilation/diag14818.d(41): Candidates are:
fail_compilation/diag14818.d(24): Foo(T) if (is(T == int))
Expand Down
54 changes: 27 additions & 27 deletions compiler/test/fail_compilation/diag8101.d
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag8101.d(62): Error: function `f_0` is not callable using argument types `()`
fail_compilation/diag8101.d(62): too few arguments, expected 1, got 0
fail_compilation/diag8101.d(34): `diag8101.f_0(int)` declared here
fail_compilation/diag8101.d(63): Error: none of the overloads of `f_1` are callable using argument types `()`
fail_compilation/diag8101.d(36): Candidates are: `diag8101.f_1(int)`
fail_compilation/diag8101.d(37): `diag8101.f_1(int, int)`
fail_compilation/diag8101.d(64): Error: none of the overloads of `f_2` are callable using argument types `()`
fail_compilation/diag8101.d(39): Candidates are: `diag8101.f_2(int)`
fail_compilation/diag8101.d(40): `diag8101.f_2(int, int)`
fail_compilation/diag8101.d(41): `diag8101.f_2(int, int, int)`
fail_compilation/diag8101.d(42): `diag8101.f_2(int, int, int, int)`
fail_compilation/diag8101.d(43): `diag8101.f_2(int, int, int, int, int)`
fail_compilation/diag8101.d(44): `diag8101.f_2(int, int, int, int, int, int)`
fail_compilation/diag8101.d(64): ... (1 more, -v to show) ...
fail_compilation/diag8101.d(66): Error: template `t_0` is not callable using argument types `!()()`
fail_compilation/diag8101.d(47): Candidate is: `t_0(T1)()`
fail_compilation/diag8101.d(67): Error: none of the overloads of template `diag8101.t_1` are callable using argument types `!()()`
fail_compilation/diag8101.d(49): Candidates are: `t_1(T1)()`
fail_compilation/diag8101.d(50): `t_1(T1, T2)()`
fail_compilation/diag8101.d(68): Error: none of the overloads of template `diag8101.t_2` are callable using argument types `!()()`
fail_compilation/diag8101.d(52): Candidates are: `t_2(T1)()`
fail_compilation/diag8101.d(53): `t_2(T1, T2)()`
fail_compilation/diag8101.d(54): `t_2(T1, T2, T3)()`
fail_compilation/diag8101.d(55): `t_2(T1, T2, T3, T4)()`
fail_compilation/diag8101.d(56): `t_2(T1, T2, T3, T4, T5)()`
fail_compilation/diag8101.d(57): `t_2(T1, T2, T3, T4, T5, T6)()`
fail_compilation/diag8101.d(68): ... (1 more, -v to show) ...
fail_compilation\diag8101.d(62): Error: function `f_0` is not callable using argument types `()`
fail_compilation\diag8101.d(62): too few arguments, expected 1, got 0
fail_compilation\diag8101.d(34): `diag8101.f_0(int)` declared here
fail_compilation\diag8101.d(63): Error: none of the overloads of `f_1` are callable using argument types `()`
fail_compilation\diag8101.d(36): Candidate 1 is: `diag8101.f_1(int)`
fail_compilation\diag8101.d(37): Candidate 2 is: `diag8101.f_1(int, int)`
fail_compilation\diag8101.d(64): Error: none of the overloads of `f_2` are callable using argument types `()`
fail_compilation\diag8101.d(39): Candidate 1 is: `diag8101.f_2(int)`
fail_compilation\diag8101.d(40): Candidate 2 is: `diag8101.f_2(int, int)`
fail_compilation\diag8101.d(41): Candidate 3 is: `diag8101.f_2(int, int, int)`
fail_compilation\diag8101.d(42): Candidate 4 is: `diag8101.f_2(int, int, int, int)`
fail_compilation\diag8101.d(43): Candidate 5 is: `diag8101.f_2(int, int, int, int, int)`
fail_compilation\diag8101.d(44): Candidate 6 is: `diag8101.f_2(int, int, int, int, int, int)`
fail_compilation\diag8101.d(64): ... (1 more, -v to show) ...
fail_compilation\diag8101.d(66): Error: template `t_0` is not callable using argument types `!()()`
fail_compilation\diag8101.d(47): Candidate is: `t_0(T1)()`
fail_compilation\diag8101.d(67): Error: none of the overloads of template `diag8101.t_1` are callable using argument types `!()()`
fail_compilation\diag8101.d(49): Candidate 1 is: `t_1(T1)()`
fail_compilation\diag8101.d(50): Candidate 2 is: `t_1(T1, T2)()`
fail_compilation\diag8101.d(68): Error: none of the overloads of template `diag8101.t_2` are callable using argument types `!()()`
fail_compilation\diag8101.d(52): Candidate 1 is: `t_2(T1)()`
fail_compilation\diag8101.d(53): Candidate 2 is: `t_2(T1, T2)()`
fail_compilation\diag8101.d(54): Candidate 3 is: `t_2(T1, T2, T3)()`
fail_compilation\diag8101.d(55): Candidate 4 is: `t_2(T1, T2, T3, T4)()`
fail_compilation\diag8101.d(56): Candidate 5 is: `t_2(T1, T2, T3, T4, T5)()`
fail_compilation\diag8101.d(57): Candidate 6 is: `t_2(T1, T2, T3, T4, T5, T6)()`
fail_compilation\diag8101.d(68): ... (1 more, -v to show) ...
---
*/

Expand Down
20 changes: 10 additions & 10 deletions compiler/test/fail_compilation/diag8101b.d
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag8101b.d(28): Error: none of the overloads of `foo` are callable using argument types `(double)`
fail_compilation/diag8101b.d(19): Candidates are: `diag8101b.S.foo(int __param_0)`
fail_compilation/diag8101b.d(20): `diag8101b.S.foo(int __param_0, int __param_1)`
fail_compilation/diag8101b.d(30): Error: function `diag8101b.S.bar(int __param_0)` is not callable using argument types `(double)`
fail_compilation/diag8101b.d(30): cannot pass argument `1.0` of type `double` to parameter `int __param_0`
fail_compilation/diag8101b.d(33): Error: none of the overloads of `foo` are callable using a `const` object with argument types `(int)`
fail_compilation/diag8101b.d(19): Candidates are: `diag8101b.S.foo(int __param_0)`
fail_compilation/diag8101b.d(20): `diag8101b.S.foo(int __param_0, int __param_1)`
fail_compilation/diag8101b.d(35): Error: mutable method `diag8101b.S.bar` is not callable using a `const` object
fail_compilation/diag8101b.d(22): Consider adding `const` or `inout` here
fail_compilation\diag8101b.d(28): Error: none of the overloads of `foo` are callable using argument types `(double)`
fail_compilation\diag8101b.d(19): Candidate 1 is: `diag8101b.S.foo(int __param_0)`
fail_compilation\diag8101b.d(20): Candidate 2 is: `diag8101b.S.foo(int __param_0, int __param_1)`
fail_compilation\diag8101b.d(30): Error: function `diag8101b.S.bar(int __param_0)` is not callable using argument types `(double)`
fail_compilation\diag8101b.d(30): cannot pass argument `1.0` of type `double` to parameter `int __param_0`
fail_compilation\diag8101b.d(33): Error: none of the overloads of `foo` are callable using a `const` object with argument types `(int)`
fail_compilation\diag8101b.d(19): Candidate 1 is: `diag8101b.S.foo(int __param_0)`
fail_compilation\diag8101b.d(20): Candidate 2 is: `diag8101b.S.foo(int __param_0, int __param_1)`
fail_compilation\diag8101b.d(35): Error: mutable method `diag8101b.S.bar` is not callable using a `const` object
fail_compilation\diag8101b.d(22): Consider adding `const` or `inout` here
---
*/

Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/fail14997.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
TEST_OUTPUT:
---
fail_compilation/fail14997.d(19): Error: none of the overloads of `this` are callable using argument types `()`
fail_compilation/fail14997.d(14): Candidates are: `fail14997.Foo.this(int a)`
fail_compilation/fail14997.d(15): `fail14997.Foo.this(string a)`
fail_compilation/fail14997.d(14): Candidate 1 is: `fail14997.Foo.this(int a)`
fail_compilation/fail14997.d(15): Candidate 2 is: `fail14997.Foo.this(string a)`
---
*/

Expand Down
12 changes: 6 additions & 6 deletions compiler/test/fail_compilation/fail15616a.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
TEST_OUTPUT:
---
fail_compilation/fail15616a.d(41): Error: none of the overloads of `foo` are callable using argument types `(double)`
fail_compilation/fail15616a.d(14): Candidates are: `fail15616a.foo(int a)`
fail_compilation/fail15616a.d(17): `fail15616a.foo(int a, int b)`
fail_compilation/fail15616a.d(26): `fail15616a.foo(int a, int b, int c)`
fail_compilation/fail15616a.d(29): `fail15616a.foo(string a)`
fail_compilation/fail15616a.d(32): `fail15616a.foo(string a, string b)`
fail_compilation\fail15616a.d(35): `fail15616a.foo(string a, string b, string c)`
fail_compilation/fail15616a.d(14): Candidate 1 is: `fail15616a.foo(int a)`
fail_compilation/fail15616a.d(17): Candidate 2 is: `fail15616a.foo(int a, int b)`
fail_compilation/fail15616a.d(26): Candidate 3 is: `fail15616a.foo(int a, int b, int c)`
fail_compilation/fail15616a.d(29): Candidate 4 is: `fail15616a.foo(string a)`
fail_compilation/fail15616a.d(32): Candidate 5 is: `fail15616a.foo(string a, string b)`
fail_compilation/fail15616a.d(35): Candidate 6 is: `fail15616a.foo(string a, string b, string c)`
fail_compilation/fail15616a.d(41): ... (2 more, -v to show) ...
---
*/
Expand Down
Loading
Loading