<div><font face="courier new, monospace">Greetings</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">I observed that struct type function call arguments do not implicitly convert even when I define a valid constructor for type conversion. So DMD complains for line 15 in the code listed below saying:</font></div>
<div><font face="courier new, monospace"><div>test.d(15): Error: function test.fiz (Bar _bar) is not callable using argument types (Foo)</div><div>test.d(15): Error: cannot implicitly convert expression (foo) of type Foo to Bar</div>
<div><br></div><div>Is this a bug, or is it intended behavior? If it is a bug, can somebody please point me to the issue number filed on Bugzilla so that I can track it. I made some effort to search it myself but could find it on Bugzilla.</div>
<div><br></div><div>And if it is intended behavior, I guess it is because of some issues with template function matching. But I find explicit casting while calling functions a bit of a stretch.</div><div><br></div><div>Regards</div>
<div>- Puneet</div><div><br></div></font></div><font face="courier new, monospace">struct Foo { } // 1<br> // 2<br>struct Bar { // 3<br> this (Foo _foo) { } // 4<br>
void opAssign(Foo _foo) { } // 5<br>} // 6<br> // 7<br>void fiz(Bar _bar) { } // 8<br> // 9<br>void main() { // 10<br>
Foo foo; // 11<br> // implicit conversion works // 12<br> Bar bar = foo; // 13<br> // But not here // 14<br> fiz(foo); // 15<br>} // 16</font><br>
<div><font face="courier new, monospace"><br></font></div>