Skip to content

Commit 93e5dce

Browse files
pbackusdlang-bot
authored andcommitted
Fix issue 23062 - Function/delegate inference example does not compile
1 parent c964f48 commit 93e5dce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spec/expression.dd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,17 +1940,17 @@ $(GNAME FunctionLiteralBody2):
19401940

19411941
-------------
19421942
int abc(int delegate(int i));
1943-
int def(int function(int s));
1943+
int def(uint function(uint s));
19441944

19451945
void test()
19461946
{
19471947
int b = 3;
19481948

1949-
abc( int(int c) { return 6 + b; } ); // inferred to delegate
1950-
def( uint(uint c) { return c * 2; } ); // inferred to function
1951-
//def( int(int c) { return c * b; } ); // error!
1952-
// Because the FunctionLiteralBody accesses b, then the function literal type
1953-
// is inferred to delegate. But def cannot accept a delegate argument.
1949+
abc( (int c) { return 6 + b; } ); // inferred as delegate
1950+
def( (uint c) { return c * 2; } ); // inferred as function
1951+
//def( (uint c) { return c * b; } ); // error!
1952+
// Because the FunctionLiteralBody accesses b, the function literal type
1953+
// is inferred as delegate. But def cannot accept a delegate argument.
19541954
}
19551955
-------------
19561956

0 commit comments

Comments
 (0)