www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22240] New: Erroneous overload selection bool vs long


          Issue ID: 22240
           Summary: Erroneous overload selection bool vs long
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: deadalnix gmail.com

import std.stdio;

void foo(bool b) {
    writeln("This is bool!");

void foo(long l) {
    writeln("This is bool!");

As expected by nobody, foo(0) and foo(1) actually call foo(bool). Every other
integer value or a non constant integer value ends up calling foo(long).

I assume that VRP detects that 0 and 1 can be coerced into bools, but even in
this case, this should error with an error mentionning that overload
resolutionf ailed as there are two candidates.

There are 0 circumstance where the VRP call should be preferred to the non VRP

Aug 25 2021