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.
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
https://github.com/D-Programming-Language/dmd/pull/831
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d2183ba7aab0d62b91ac230e8a532e9a14699c2f Merge pull request #831 from 9rnsr/fix7743 Issue 7743 - Parsing problem with nothrow delegate