D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21254 - Terse lambda syntax does not allow specifying ref return type
Summary: Terse lambda syntax does not allow specifying ref return type
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-16 05:20 UTC by Andrej Mitrovic
Modified: 2020-09-16 05:33 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2020-09-16 05:20:40 UTC
-----
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;
}
-----
Comment 1 ag0aep6g 2020-09-16 05:33:01 UTC
It's:

    auto get = ref (ref S s) => s.val;

Closing as invalid.