DIP-1000 and return
    Nordlöw via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Jan  1 09:41:46 PST 2017
    
    
  
The code
auto asStatic(T, size_t length)(T[length] arr)
{
     return arr;
}
@safe pure nothrow @nogc unittest
{
     auto x = [1, 2, 3].asStatic;
     static assert(is(typeof(x) == int[x.length]));
     static assert(is(typeof([1, 2, 3].asStatic) == 
int[x.length]));
}
now fails on Git master (after DIP-1000 has been merged) as
array_ex.d(55,6): Error: parameter arr is 'return' but function 
does not return any indirections
array_ex.d(63,23): Error: template instance 
array_ex.asStatic!(int, 3LU) error instantiating
array_ex.d(64,5): Error: static assert  (is(typeof(x) == 
int[x.length])) is false
I tried qualifying argument with `return ref` as described at
https://wiki.dlang.org/DIP25
but that fails because parameter must be allowed to be an r-value 
aswell.
Any clues?
    
    
More information about the Digitalmars-d-learn
mailing list