Parantheses around method invokation: why is the compiler complaining about assignment?
- by polygenelubricants
I know why the following code doesn't compile:
public class Main {
public static void main(String args[]) {
main((null)); // this is fine!
(main(null)); // this is NOT!
}
}
What I'm wondering is why my compiler (javac 1.6.0_17, Windows version) is complaining "The left hand side of an assignment must be a variable".
I'd expect something like "Don't put parantheses around a method invokation, dummy!", instead.
So why is the compiler making a totally unhelpful complaint about something that is blatantly irrelevant?
Is this the result of an ambiguity in the grammar? A bug in the compiler?
If it's the former, could you design a language such that a compiler would never be so off-base about a syntax error like this?