Comment #0 by bearophile_hugs — 2012-03-20T19:53:27Z
This code compiles with no errors:
auto foo() {
int x;
return delegate() nothrow {
return x;
};
}
void main() {}
But with this version:
auto foo() {
int x;
return () nothrow {
return x;
};
}
void main() {}
DMD 2.059head gives:
test.d(3): expression expected, not ')'
test.d(3): found 'nothrow' when expecting ')'
test.d(3): found '{' when expecting ';' following return statement
test.d(6): unrecognized declaration
Maybe similar issues happens with other annotations.
Comment #1 by timon.gehr — 2012-03-21T13:41:04Z
The grammar on dlang.org indicates that it should work.
FunctionLiteral:
function Typeopt ParameterAttributes opt FunctionBody
delegate Typeopt ParameterAttributes opt FunctionBody
ParameterAttributes FunctionBody <<<
FunctionBody
ParameterAttributes:
Parameters
Parameters FunctionAttributes <<<
FunctionAttribute:
nothrow <<<
pure
Property