Bug 21338 – Confusing error message for template overload resolution failure

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-10-22T20:15:48Z
Last change time
2022-10-31T22:14:47Z
Keywords
pull
Assigned to
No Owner
Creator
crazymonkyyy

Comments

Comment #0 by crazymonkyyy — 2020-10-22T20:15:48Z
https://run.dlang.io/is/UxBhfw import std; void main() { writeln("Learning D is fun".split!isWhite); } This is copy and pasted from the unittests, it behaves different based on scope to the point I'm not sure "auto split(alias isTerminator, Range)(Range range)" can exist outside of std code.
Comment #1 by alphaglosined — 2021-04-06T12:57:14Z
This appears to be a symbol lookup bug associated with importing of the std package module. Adding: import std.uni : isWhite; Fixes it due to conflicts with std.ascii.
Comment #2 by snarwin+bugzilla — 2021-04-06T13:07:59Z
Reduced example: --- import std.array, std.regex, std.uni, std.ascii; void main() { auto example = "Learning D is fun".split!isWhite; } --- Fails to compile and produces the error message: --- onlineapp.d(4): Error: no overload matches for split --- The compilation failure is caused by ambiguity between `std.uni.isWhite` and `std.ascii.isWhite`. Removing either `std.uni` or `std.ascii` from the import causes the code to compile. The confusing error message is caused by ambiguity between `std.array.split` and `std.regex.split`. Removing either `std.array` or `std.regex` causes it to fail with a more informative error message.
Comment #3 by dlang-bot — 2022-10-31T12:18:11Z
@ntrel created dlang/dmd pull request #14605 "Fix Issue 21338 - Confusing error message for template overload resol…" fixing this issue: - Fix Issue 21338 - Confusing error message for template overload resolution failure Show candidates. https://github.com/dlang/dmd/pull/14605
Comment #4 by dlang-bot — 2022-10-31T14:58:34Z
dlang/dmd pull request #14605 "Fix Issue 21338 - Confusing error message for template overload resol…" was merged into master: - f5b654f4c047b871b9238a9e75b77c932be0b7fa by Nick Treleaven: Fix Issue 21338 - Confusing error message for template overload resolution failure Show expression, not just identifier. Show candidates. https://github.com/dlang/dmd/pull/14605
Comment #5 by nick — 2022-10-31T15:38:38Z
With https://github.com/dlang/dmd/pull/14606 too, the error will be: splitoverload.d(7): Error: no overload matches for `split("Learning D is fun")` splitoverload.d(7): Candidates are: std\regex\package.d(1695): split(String, RegEx)(String input, RegEx rx) if (isSomeString!String && isRegexFor!(RegEx, String)) std\array.d(1924): split(S)(S s) if (isSomeString!S) std\array.d(2030): split(Range, Separator)(Range range, Separator sep) if (isForwardRange!Range && (is(typeof(ElementType!Range.init == Separator.init)) || is(typeof(ElementType!Range.init == ElementType!Separator.init)) && isForwardRange!Separator)) std\array.d(2040): split(alias isTerminator, Range)(Range range) if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(range.front)))) At least now the user may try disambiguating `split` and then they will see the constraint failure message for the isTerminator overload. It is still confusing why that fails, but they may then try calling `isWhite(' ')` manually and see the (existing) error message: splitoverload.d(13): Error: function `std.ascii.isWhite` at C:\D\dmd2\windows\bin\..\..\src\phobos\std\ascii.d(411) conflicts with function `std.uni.isWhite` at C:\D\dmd2\windows\bin\..\..\src\phobos\std\uni\package.d(8907)
Comment #6 by dlang-bot — 2022-10-31T22:14:47Z
dlang/dmd pull request #14606 "Fix missing overloads in call candidate list" was merged into master: - c8077406b181315213f2baa53ac021bbdb2fcb1f by Nick Treleaven: Fix missing overloads in call candidate list Also fix missing non-template function parameter. Part of Issue 21338 - Confusing error message for template overload resolution failure. https://github.com/dlang/dmd/pull/14606