To determine whether or not it's a bug in the compiler, you need to look at the C# spec - in this case section 7.6.10.6, which clearly allows it:
anonymous-object-creation-expression:
new anonymous-object-initializer
anonymous-object-initializer:
{ member-declarator-listopt }
{ member-declarator-list , }
So no, it's not a compiler bug. The language was deliberately designed to allow it.
Now as for why the language has been designed that way - I believe it's to make it easier to add and remove values when coding. For example:
var obj = new {
field1 = "test",
field2 = 3,
};
can become
var obj = new {
field2 = 3,
};
or
var obj = new {
field1 = "test",
field2 = 3,
field3 = 4,
};
solely by adding or removing a line. This makes it simpler to maintain code, and also easier to write code generators.
Note that this is consistent with array initializers, collection initializers and enums:
// These are all valid
string[] array = { "hello", };
List<string> list = new List<string> { "hello", };
enum Foo { Bar, }