[Issue 9999] Integer literal 0 and 1 should prefer integer type in overload resolution

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Feb 1 11:45:08 PST 2015


https://issues.dlang.org/show_bug.cgi?id=9999

Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg at gmail.com

--- Comment #12 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
Also this issue has to terrible consequences:
1. `f(bool)` is preferred over `f(T)(T)`
2. expressions like `4 - 3` triggers the issue too


This code should run fine:
---
int f1(bool) { return 1; }
int f1(T)(T) { return 2; }

void f2()(bool) { static assert(0); }
void f2(T)(T) { }

void main()
{
    assert(f1(    0) == 2);  // fails
    assert(f1(    1) == 2);  // fails
    assert(f1(   1U) == 2);  // fails
    assert(f1(4 - 3) == 2);  // fails

    f2(    0);  // triggers `static assert(0)`
    f2(    1);  // ditto
    f2(   1U);  // ditto
    f2(4 - 3);  // ditto
}
---

--


More information about the Digitalmars-d-bugs mailing list