Skip to content

Conversation

Poita
Copy link
Contributor

@Poita Poita commented Jul 22, 2015

#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.

dlang#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.
@Poita
Copy link
Contributor Author

Poita commented Jul 22, 2015

I recommend viewing diff with whitespace ignored: https://github.com/D-Programming-Language/phobos/pull/3509/files?w=1

@quickfur
Copy link
Member

Makes sense to me. Though I can't say I'm pleased with the gratuitous naming conflict between std.file.copy and std.algorithm.copy. But that's outside the scope of this PR.

@WalterBright
Copy link
Member

You can still make it one function. Use a constraint that ORs the constraints for the two overloads.

Also needs a unit test to verify the fix.

@MartinNowak
Copy link
Member

AFAIK this should go into stable b/c it fixes a regression.
My mistake.

@9rnsr 9rnsr changed the title Fix Issue 14817 - std.algorithm.copy/std.file.copy conflict [REG-master] Fix Issue 14817 - std.algorithm.copy/std.file.copy conflict Jul 25, 2015
@DmitryOlshansky
Copy link
Member

@Poita - add a unittest for the fix and it should be good to go.

Personally I think splitting the function makes it simpler then following all of static if/else chains.

@WalterBright
Copy link
Member

splitting the function makes it simpler then following all of static if/else chains.

Harder for the user reading the documentation, though.

@DmitryOlshansky
Copy link
Member

Ping @Poita

@DmitryOlshansky
Copy link
Member

See #3649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants