On Wednesday, 18 September 2013 at 13:23:10 UTC, Namespace wrote:
Code:
----
const { /// [1]
int a = 3;
}
void main()
{
const { /// [2]
int b = 4;
}
}
----
Why is [1] allowed, but not [2]?
Citing grammar:
FunctionBody:
BlockStatement
BodyStatement
InStatement BodyStatement
OutStatement BodyStatement
InStatement OutStatement BodyStatement
OutStatement InStatement BodyStatement
BlockStatement:
{ }
{ StatementList }
As you can see there is no room for attributes. Why dmd does not
support attributes here is separate question - probably because
such construct would be confused with lambda, but this is not a
serious reason.