Bug 5050 – No way to declare delegates with ref return
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-10-13T11:48:54Z
Last change time
2019-04-07T16:18:45Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2010-10-13T11:48:54Z
ref int delegate( ref int ) r = ( ref int a ) { return a; };
The above gives "found 'ref' instead of statement"
Comment #1 by hsteoh — 2014-01-15T08:36:35Z
Still happens on latest git HEAD. :-(
Comment #2 by bugzilla — 2014-12-08T05:14:01Z
You can do it with an alias:
alias ref int delegate(ref int) dg_t;
dg_t r = ...;
Comment #3 by dlang-bot — 2019-04-05T20:06:17Z
@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 by dlang-bot — 2019-04-07T16:18:45Z
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