Created attachment 1824
code with confususion, line 50
import std;
struct bar{
int i;
}
struct foo{
bar i; alias i this;
}
void foobar(bar[] yo){
//void foobar(T:bar[])(T yo){
"bar[]".writeln;
}
void foobar(T:foo)(T[3] t){
"foo[3]".writeln;}
unittest{
foobar([foo(),foo(),foo()]);
}
---
I would suggest throwing in a note that says something like "int[3] matches to string before T[3] this can be fixed by redefining string function to '(T:string)(T s)'"
Comment #1 by maxhaton — 2021-07-20T00:05:25Z
Is this not implied by the existing overload matching rules?
Comment #2 by crazymonkyyy — 2021-07-30T20:43:56Z
(In reply to mhh from comment #1)
> Is this not implied by the existing overload matching rules?
You were part of the conversation on discord and didnt see it either?
its implied if I understand the rules, but unclear.
the implicit int to char and char[] being close enough to strings was very surprising given a foo(intT)(intT[3]) and foo(string) overloads
Comment #3 by dfj1esp02 — 2021-08-02T12:26:27Z
A more meaningful example:
---
struct Address
{
this(in char[] host, int port){}
this(ubyte[4] ip, int port){}
}
auto addr=Address([127,0,0,1],80);
---
I wanted overloads for host name and ip address, but they are ambiguous.
Comment #4 by robert.schadek — 2024-12-15T15:27:05Z