[Issue 23308] New: Can't resolve overload of varargs function if one parameter is the result of a ternary expression
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 28 18:49:21 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23308
Issue ID: 23308
Summary: Can't resolve overload of varargs function if one
parameter is the result of a ternary expression
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kytodragon at e.mail.de
This code:
```
void foo(string a) {}
void foo(A...)(A a) {}
void bar(bool condition, void* param) {
float s32;
foo(condition ? param : &s32);
}
```
results in the following error message:
```
test.d(8): Error: none of the overloads of `foo` are callable using argument
types `(float*)`, candidates are:
test.d(2): `example.foo(string a)`
test.d(4): `foo(A...)(A a)`
```
If the condition is removed or if the values inside the ternary expression are
cast to the same type, the error goes away.
```
foo(condition ? param : cast(void*)&s32);
```
The error message also references the wrong type, better seen in this example:
```
void foo(float* a) {}
void bar(bool condition, void* param) {
float s32;
foo(condition ? param : &s32);
}
```
```
test.d(5): Error: function `example.foo(float* a)` is not callable using
argument types `(float*)`
test.d(5): cannot pass argument `condition ? param : & s32` of type
`float*` to parameter `float* a`
```
Reproducible with all versions of DMD and LDC.
--
More information about the Digitalmars-d-bugs
mailing list