www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11181] New: Missing compile-time error for wrong array literal


           Summary: Missing compile-time error for wrong array literal
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc

--- Comment #0 from bearophile_hugs eml.cc 2013-10-06 02:58:30 PDT ---
void main() {
    const string[][] a = [["a", "b"], "x"];

DMD 2.064 alpha gives the right error:

test.d(2): Error: incompatible types for ((["a", "b"]) : ("x")): 'string[]' and


void main() {
    auto a = ["a", "b"];
    const string[][] b = [a[0 .. $], "x"];

Gives no compile-time errors, and gives at run-time:

object.Error: array cast misalignment

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 06 2013