D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7743 - Parsing problem with nothrow delegate
Summary: Parsing problem with nothrow delegate
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-03-20 19:53 UTC by bearophile_hugs
Modified: 2012-03-24 23:35 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-03-20 19:53:27 UTC
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 timon.gehr 2012-03-21 13:41:04 UTC
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
Comment 3 github-bugzilla 2012-03-24 22:27:49 UTC
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