D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5050 - No way to declare delegates with ref return
Summary: No way to declare delegates with ref return
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2010-10-13 11:48 UTC by Simen Kjaeraas
Modified: 2019-04-07 16:18 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2010-10-13 11:48:54 UTC
ref int delegate( ref int ) r = ( ref int a ) { return a; };

The above gives "found 'ref' instead of statement"
Comment 1 hsteoh 2014-01-15 08:36:35 UTC
Still happens on latest git HEAD. :-(
Comment 2 Walter Bright 2014-12-08 05:14:01 UTC
You can do it with an alias:

    alias ref int delegate(ref int) dg_t;
    dg_t r = ...;
Comment 3 Dlang Bot 2019-04-05 20:06:17 UTC
@BorisCarvajal updated dlang/dmd pull request #9558 "Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference" fixing this issue:

- Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference

https://github.com/dlang/dmd/pull/9558
Comment 4 Dlang Bot 2019-04-07 16:18:45 UTC
dlang/dmd pull request #9558 "Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference" was merged into master:

- 60251b8f0e191a8f0f5142ddd2d3807d0e06c58a by Boris Carvajal:
  Fixes issues 16271, 18825, 8065, 5050 - Allow function literals return by reference

https://github.com/dlang/dmd/pull/9558