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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Dec 10 01:58:11 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13849

          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 at puremagic.com
          Reporter: bearophile_hugs at 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
uint[2]


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
uint[2]

--


More information about the Digitalmars-d-bugs mailing list