Bug 14817 – [REG-master] copy("foo", "bar") std.algorithm/std.file conflict

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-21T12:29:00Z
Last change time
2015-10-04T18:20:56Z
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2015-07-21T12:29:42Z
/////////// test.d /////////// import std.algorithm; import std.file; void main() { copy("test.d", "test2.d"); } ////////////////////////////// C:\...\std\algorithm\mutation.d(315): Error: cannot modify immutable expression target[idx] C:\...\std\algorithm\mutation.d(323): Error: slice target[0..slen] is not mutable test.d(6): Error: template instance std.algorithm.mutation.copy!(string, string) error instantiating test.d(6): Error: std.file.copy!(string, string).copy at C:\...\std\file.d(2781) conflicts with std.algorithm.mutation.copy!(string, string).copy at C:\...\std\algorithm\mutation.d(297) This is a regression because previously the invariant of std.algorithm.mutation.copy apparently did not accept (immutable) strings as a target. This broke building Digger (along with issue 14765). Introduced in https://github.com/D-Programming-Language/phobos/pull/2799
Comment #1 by peter.alexander.au — 2015-07-21T14:43:26Z
I see, I'll fix this as soon as I can. I'm not understanding something though: I thought anti-hijacking rules were supposed to stop symbols from one module overloading with symbols from another? Shouldn't these two symbols be in conflict *regardless* of whether or not std.algorithm.mutation.copy had the template constraint?
Comment #2 by dlang-bugzilla — 2015-07-21T14:47:58Z
As I understand template constraints allow excluding functions from overload resolution if the constraints do not pass.
Comment #3 by peter.alexander.au — 2015-07-22T00:19:02Z
Comment #4 by github-bugzilla — 2015-09-18T13:22:06Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/1e7246b20128efc94dd7525bdbb58e8ee171ca5e Fix Issue 14817 - std.algorithm.copy/std.file.copy conflict https://github.com/D-Programming-Language/phobos/pull/2799 introduced a regression, which prevented module that imported both std.algorithm and std.file to use unqualified calls to copy(string, string). The regression was caused by the removal of template constraints, which were preventing the std.algorithm copy from being considered for overload resolution. std.algorithm.copy has two paths: an path for array copies, and a path for all other copies. Previously they were forked using static if inside function. Now the decision is made using template constraints. https://github.com/D-Programming-Language/phobos/commit/f9a6e0b0dd249b8c36820920ae848a3966699352 Add test for issue 14817 https://github.com/D-Programming-Language/phobos/commit/edc405cacd1a60c3e09236bc8b2cca39b271e6b3 Merge pull request #3649 from DmitryOlshansky/poita--issue14817 [REG master] Issue14817 std.algorithm.copy/std.file.copy conflict
Comment #5 by github-bugzilla — 2015-10-04T18:20:56Z