unittest
{
alias abc = in { } out { } body { return 100; };
alias abc = () in{ } out { } body { return 100; };
alias abc = () @nogc in{ } out { } body { return 100; };
doThings(in { } out { } body { return 100; });
auto a = in { } out { } body { return 100; };
}
All of these are valid according to the grammar due to the way that the FunctionLiteralBody rule includes optional contracts. The compiler rejects all of them.
Which is correct, compiler or grammar?
Comment #1 by bugzilla — 2019-12-23T10:59:43Z
FunctionLiteralBody seems to be defined twice (and differently) on [1], once inside "functions" and once inside "expressions".
[1] https://dlang.org/spec/grammar.html
Comment #2 by nick — 2022-07-23T13:53:31Z
I've made a pull to fix this for a more recent duplicate, so closing this.
The grammar is now automatically generated.
*** This issue has been marked as a duplicate of issue 19869 ***