www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21254] New: Terse lambda syntax does not allow specifying ref

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

          Issue ID: 21254
           Summary: Terse lambda syntax does not allow specifying ref
                    return type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
struct S
{
    int val;
}

auto get = (ref S s) => s.val;  // returns rvalue, not usable for our case

ref get = (ref S s) => s.val;  // Error: variable `test.get` only parameters or
`foreach` declarations can be `ref`

void main ()
{
    S s;
    s.get() = 10;
}
-----

--
Sep 15 2020