www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10884] New: Support for using alias expressions to shorten inferred function types

http://d.puremagic.com/issues/show_bug.cgi?id=10884

           Summary: Support for using alias expressions to shorten
                    inferred function types
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



I tagged this as enhancement but I consider it as borderline bug report:


struct Foo(T) { T x; }
void bar1(T)(Foo!T c) {}
alias F(T) = Foo!T;
void bar2(T)(F!T c) {} // line 4, error
void main() {
    F!int x = Foo!int(1);
    bar1(x); // OK
    bar2(x); // line 8, error
}



dmd 2.064alpha:

test.d(8): Error: template test.bar2 does not match any function template
declaration. Candidates are:
test.d(4):        test.bar2(T)(F!T c)
test.d(8): Error: template test.bar2(T)(F!T c) cannot deduce template function
from argument types !()(Foo!int)


Support for similar code is handy to use alias expressions to shorten code when
the same complex type is used in many function signatures, like in bar2.

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