Bug 23062 – Function/delegate inference example does not compile
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-26T15:15:44Z
Last change time
2022-04-26T15:42:13Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2022-04-26T15:15:44Z
In the spec's section on function literals [1], the example demonstrating inference of the `function` and `delegate` keywords does not compile, due to multiple parsing errors.
---
int abc(int delegate(int i));
int def(int function(int s));
void test()
{
int b = 3;
abc( int(int c) { return 6 + b; } ); // inferred to delegate
def( uint(uint c) { return c * 2; } ); // inferred to function
//def( int(int c) { return c * b; } ); // error!
// Because the FunctionLiteralBody accesses b, then the function literal type
// is inferred to delegate. But def cannot accept a delegate argument.
}
---
[1]: https://dlang.org/spec/expression.html#function_literals
Comment #1 by dlang-bot — 2022-04-26T15:17:05Z
@pbackus created dlang/dlang.org pull request #3286 "Fix issue 23062 - Function/delegate inference example does not compile" fixing this issue:
- Fix issue 23062 - Function/delegate inference example does not compile
https://github.com/dlang/dlang.org/pull/3286
Comment #2 by dlang-bot — 2022-04-26T15:42:13Z
dlang/dlang.org pull request #3286 "Fix issue 23062 - Function/delegate inference example does not compile" was merged into master:
- 86a7d5b769ca6d101663b642395ba8fbdbc7dec8 by Paul Backus:
Fix issue 23062 - Function/delegate inference example does not compile
https://github.com/dlang/dlang.org/pull/3286