[Issue 19749] New: Inout causes wrong type inference
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Mar 18 10:38:32 UTC 2019
    
    
  
https://issues.dlang.org/show_bug.cgi?id=19749
          Issue ID: 19749
           Summary: Inout causes wrong type inference
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ali.akhtarzada at gmail.com
Using inout with type constructors causes the wrong type to be inferred.
struct S(T) {
    T value = T.init;
}
auto ref make(T)(inout auto ref T value) {
    // T == char[] when infact it's string 
    return inout(S!T)(value);
}
auto ref f(T)(inout auto ref S!T s) {
    return make(s.value);
}
auto a = [make("hello"), S!string("hello")];
Probably related to 19126.
--
    
    
More information about the Digitalmars-d-bugs
mailing list