[Issue 21457] New: std.functional.partial ignores function overloads
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 6 21:39:54 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21457
Issue ID: 21457
Summary: std.functional.partial ignores function overloads
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list