D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23062 - Function/delegate inference example does not compile
Summary: Function/delegate inference example does not compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-04-26 15:15 UTC by Paul Backus
Modified: 2022-04-26 15:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2022-04-26 15:15:44 UTC
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 Dlang Bot 2022-04-26 15:17:05 UTC
@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 Dlang Bot 2022-04-26 15:42:13 UTC
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