rearranged parseBlock a bit for better error messages
text/plain
2732
Comments
Comment #0 by bearophile_hugs — 2010-06-06T06:34:41Z
This D2 program compiles and runs with v2.046, but the syntax is wrong:
template Foo(bool b) {
static if (b)
enum bool Foo = 1;
else
}
static assert(Foo!(true) == 1);
void main() {}
Comment #1 by ellery-newcomer — 2010-06-06T12:15:49Z
Created attachment 658
rearranged parseBlock a bit for better error messages
Comment #2 by ellery-newcomer — 2012-08-12T23:51:08Z
The problem is if parseBlock encounters a rcurly, it consumes nothing. Otherwise, it will consume
{ decldefs }
: decldefs
decldefs
;
As near as I can tell, consuming nothing serves no purpose in the parser, but it does allow the following:
class C{
public
}
struct S{
static auto
}
interface F{
extern(C)
}
union Z{
extern private
}
class C2{
align
}
Comment #3 by k.hara.pg — 2012-10-27T07:34:11Z
https://github.com/D-Programming-Language/dmd/pull/1230
If DeclDefs is required just one declaration but there is no declaration, parseDeclDefs should raise a syntax error.
I think my pull request is much simpler than the original patch.
Comment #4 by github-bugzilla — 2012-10-27T08:43:28Z