Bug 9927 – Compiler tries to instantiate template even though a symbol conflict occurred

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-13T03:19:20Z
Last change time
2024-12-13T18:06:03Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#18562 →

Comments

Comment #0 by andrej.mitrovich — 2013-04-13T03:19:20Z
------- module test; import std.algorithm; import foo; void main() { class C { } C[] c; c.remove(new C); } ------- ------- module foo; void remove(T)(T[], T) { } ------- 2.063: $ dmd -c test.d ------- C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7412): Error: function object.Object.opCmp (Object o) is not callable using argument types (uint) C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7413): Error: function object.Object.opCmp (Object o) is not callable using argument types (uint) C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7413): Warning: statement is not reachable C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7418): Warning: statement is not reachable C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7419): Warning: statement is not reachable C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7420): Warning: statement is not reachable test.d(9): Error: template instance std.algorithm.remove!(cast(SwapStrategy)2, C[], C) error instantiating test.d(9): Error: foo.remove!(C).remove at foo.d(2) conflicts with std.algorithm.remove!(cast(SwapStrategy)2, C[], C).remove at C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7391) ------- Note the last error message, which is the only error message it should show: ------- test.d(9): Error: foo.remove!(C).remove at foo.d(2) conflicts with std.algorithm.remove!(cast(SwapStrategy)2, C[], C).remove at C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7391) ------- If there is a conflic, the compiler should not attempt to instantiate the template which is causing all these diagnostics.
Comment #1 by hsteoh — 2014-08-29T14:36:30Z
Still happens on git HEAD, but with a slightly different twist: ------ /usr/src/d/phobos/std/algorithm.d(8841): Error: function object.Object.opCmp (Object o) is not callable using argument types (ulong) /usr/src/d/phobos/std/algorithm.d(8845): Error: function object.Object.opCmp (Object o) is not callable using argument types (ulong) /usr/src/d/phobos/std/algorithm.d(8852): Error: template std.range.popFrontExactly cannot deduce function from argument types !()(C[], C), candidates are: /usr/src/d/phobos/std/range.d(4149): std.range.popFrontExactly(Range)(ref Range r, size_t n) if (isInputRange!Range) /usr/src/d/phobos/std/algorithm.d(8853): Error: template std.range.popFrontExactly cannot deduce function from argument types !()(C[], C), candidates are: /usr/src/d/phobos/std/range.d(4149): std.range.popFrontExactly(Range)(ref Range r, size_t n) if (isInputRange!Range) /usr/src/d/phobos/std/algorithm.d(8854): Error: cannot implicitly convert expression (from) of type test.main.C to ulong test.d(9): Error: template instance std.algorithm.remove!(cast(SwapStrategy)2, C[], C) error instantiating ------
Comment #2 by robert.schadek — 2024-12-13T18:06:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18562 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB