[Issue 12698] Overloads from multiple modules implicitly merge into a single overloadset
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun May 4 04:11:06 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12698
--- Comment #3 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
(In reply to Kenji Hara from comment #2)
> Why do you think this is an issue? std.algorithm.copy does not match to
> (char[], char[]) arguments, so std.file.copy is always chosen.
Because it's accidental. char[] is not an output range, but byte[] is. So the
user might without notice call functions with completely different semantics:
-----
/// Just image if the user did "import std;"
/// and the "std" package pull was merged,
/// it would be similar to the below situation:
import std.algorithm;
import std.array;
import std.conv;
import std.exception;
import std.file;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;
import std.typetuple;
void main()
{
byte[] src = [1, 2, 3];
byte[] tgt = new byte[](3);
copy(src, tgt);
writeln(tgt); // [1, 2, 3]
char[] srcname = "newname.txt".dup;
char[] tgtname = "oldname.txt".dup;
// actually *writes to a file*,
// potentially overwriting existing contents
copy(srcname, tgtname);
}
-----
--
More information about the Digitalmars-d-bugs
mailing list