Parantheses around method invokation: why is the compiler complaining about assignment?
Posted
by polygenelubricants
on Stack Overflow
See other posts from Stack Overflow
or by polygenelubricants
Published on 2010-03-24T03:06:55Z
Indexed on
2010/03/24
3:13 UTC
Read the original article
Hit count: 233
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?
© Stack Overflow or respective owner