www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11708] New: Too much weak typing of std.typecons.Typedef


           Summary: Too much weak typing of std.typecons.Typedef
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc

--- Comment #0 from bearophile_hugs eml.cc 2013-12-07 07:40:53 PST ---
This code compiles and runs with no errors with dmd 2.065alpha:

void main() {
    import std.typecons: Typedef;
    alias T = Typedef!int;
    T x;
    x = 10;
    int y = 10;
    x = y;
    T[5] arr;
    arr[0] = 10;

The point of using Typedef is to define a strong type, so I think assigning to
it with the original type should not be allowed.

And indeed the now deprecated typedef didn't allow it:

void main() {
    typedef int T;
    int y = 10;
    T x;
    x = y; // line 5, error.

temp.d(5): Error: cannot implicitly convert expression (y) of type int to T

Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 07 2013