Bug 21457 – std.functional.partial ignores function overloads
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-06T21:39:54Z
Last change time
2022-01-03T13:21:43Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2020-12-06T21:39:54Z
As of DMD 2.094.0, the following program fails to compile:
---
import std.functional;
void fun(int x, string s) {}
void fun(int x, int y) {}
alias pfun = partial!(fun, 0);
void main()
{
pfun("hello"); // ok
pfun(123); // error
}
---
The compiler's output is:
---
bug.d(11): Error: function std.functional.partial!(fun, 0).partial(string _param_0) is not callable using argument types (int)
bug.d(11): cannot pass argument 123 of type int to parameter string _param_0
---
The cause is that partial!(fun, 0)(123) is attempting to call the first overload of `fun`, when it should instead be calling the second overload.
Comment #1 by bugzilla — 2021-05-02T17:16:24Z
From source code: "// Assume fun is callable and uniquely defined."
So either this should be documented or the template be improved...
Comment #2 by dlang-bot — 2021-12-30T23:22:13Z
@wolframw created dlang/phobos pull request #8347 "Fix Issue 21457 - std.functional.partial ignores function overloads" fixing this issue:
- Fix Issue 21457 - std.functional.partial ignores function overloads
https://github.com/dlang/phobos/pull/8347
Comment #3 by dlang-bot — 2022-01-03T13:21:43Z
dlang/phobos pull request #8347 "Fix Issue 21457 - std.functional.partial ignores function overloads" was merged into master:
- 437b07980e55fa9945f7eabc3c4991ece6cc9cc8 by wolframw:
Fix Issue 21457 - std.functional.partial ignores function overloads
https://github.com/dlang/phobos/pull/8347