www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7279] New: Inconsistent overloading between arrays and scalars

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7279

           Summary: Inconsistent overloading between arrays and scalars
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



---
---
void f(int[]) { assert(0); }
void f(const int[]) { }

void g(int[]) { assert(0); }
void g(const(int)[]) { }

void h(int) { assert(0); }
void h(const int) { }

void main() {
    immutable arr = [5];
    f(arr); // Compiles
    g(arr); // Compiles

    immutable n = 5;
    h(n); // Error: ...matches both...
}
---
If f(arr) and g(arr) compiles, h(n) should compiles too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 12 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7279


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



int[] is a value with mutable indirection, so copy conversion from immutable
int[] to int[] is invalid. Then the callings of f and g with arr are solved
with no ambiguous.

But, immutable int is a value without mutable indirection, so copy conversion
from immutable int to int is *valid*. Then callings of h makes ambiguous with
the two const-conversions, immutable int -> int and immutable int -> const int.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 23 2012