www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13849] New: ulong -> uint[2] cast, and invisible error messages


          Issue ID: 13849
           Summary: ulong -> uint[2] cast, and invisible error messages
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

I think this should be accepted (this could be an enhancement request):

void main()  safe {
    immutable ulong x = 10;
    auto y1 = cast(uint[2])x;     // Error
    auto y2 = cast(uint[2])[x];   // Error
    immutable ulong[] x2 = [10];
    auto y3 = cast(uint[2])x2;    // Error
    immutable ulong[1] x3 = [10];
    auto y4 = cast(uint[2])x3;    // OK

dmd 2.067alpha gives:

test.d(3,15): Error: cannot cast expression x of type immutable(ulong) to

Another problem (this seems a bug) is that it shows only the first error
message. If you comment out the line 3 of the first error you get:

test.d(4,28): Error: e2ir: cannot cast [10LU] of type immutable(ulong)[] to
type uint[2]
test.d(6,28): Error: e2ir: cannot cast x2 of type immutable(ulong[]) to type

Dec 10 2014