Re: ushort calls byte overload

2017-05-30 Thread nkm1 via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 21:16:26 UTC, Oleg B wrote: Hello. I have this code import std.stdio; void foo(byte a) { writeln(typeof(a).stringof); } void foo(short a) { writeln(typeof(a).stringof); } void foo(int a) { writeln(typeof(a).stringof); } void main() { foo(0); // int, and byte if

Re: ushort calls byte overload

2017-05-30 Thread Oleg B via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 21:42:03 UTC, Daniel Kozak wrote: Compiler do many assumptions (it is sometimes useful). but if compiler find one-to-one correspondence it don't make assumptions, like here? import std.stdio; void f(ushort u) { writeln("ushort"); } void f(ubyte u) {

Re: ushort calls byte overload

2017-05-30 Thread Daniel Kozak via Digitalmars-d-learn
Dne 30.5.2017 v 23:16 Oleg B via Digitalmars-d-learn napsal(a): Hello. I have this code import std.stdio; void foo(byte a) { writeln(typeof(a).stringof); } void foo(short a) { writeln(typeof(a).stringof); } void foo(int a) { writeln(typeof(a).stringof); } void main() { foo(0); // int,

Re: ushort calls byte overload

2017-05-30 Thread Oleg B via Digitalmars-d-learn
and this is unexpected for me too immutable ushort y = 0; foo(y); // byte

ushort calls byte overload

2017-05-30 Thread Oleg B via Digitalmars-d-learn
Hello. I have this code import std.stdio; void foo(byte a) { writeln(typeof(a).stringof); } void foo(short a) { writeln(typeof(a).stringof); } void foo(int a) { writeln(typeof(a).stringof); } void main() { foo(0); // int, and byte if not define foo(int) foo(ushort(0)); // byte