Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Parser: give syntax error on comma after newline in argument list #6514
Code like this:
foo(x , y)
currently doesn't give a syntax error, but it should (like in Ruby). We can of course discuss whether it should really be a syntax error or not. My reasoning is that the comma signals that more arguments are coming, and it's confusing that the comma starts the next line. For example, if we remove the parentheses:
foo x , y
that won't compile. So code with and without parentheses should look more or less the same (maybe this is a weaker argument, but still...).
I believe in many other languages this is a syntax error too.
This of course is a breaking change, but I doubt there are many out there that write code like this.
This syntax option was available for many other things, like method arguments, but not available in some other things, like array literals. Now it's unified to give a syntax error.
Hmmm... actually, Java, C# and Python allow such syntax. But Ruby and Go don't. So I guess it's a matter of preference.
Right now it's behaving in a way or another depending on the case, so it's not unified. Let's use this PR to discuss what should we do with this. Maybe this PR is fine, it hurts my eyes a bit to see that stray comma there :-P