www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21437] New: const(char*) variable matches both const(char)[]


          Issue ID: 21437
           Summary: const(char*) variable matches both const(char)[] and
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: elpenguino+D gmail.com

void fun(const(char)[] a) {}
void fun(const(char)* a) {}

const(char*) a = "a";

void main() {

Without the literal to initialize it, it chooses fun(const(char)*) as expected.
With it, the compiler thinks both match and cannot choose. It should always
choose fun(const(char)*).

Nov 29 2020