Lyuben Atanasov created GROOVY-10008: ----------------------------------------
Summary: Parser: Consider adding expressions from next line to statement on current line Key: GROOVY-10008 URL: https://issues.apache.org/jira/browse/GROOVY-10008 Project: Groovy Issue Type: Wish Components: parser Reporter: Lyuben Atanasov As many people are coming from Java, there are some caveats regarding the optional semicolon at the end of a statement that are probably not well explained in the documentation. For example, the following code: {code:java} int sum = 2 + 2; {code} is compiled successfully, but the outcome is very unexpected - the variable sum will hold the value "2", and the second line effectively does nothing. A more annoying example is when porting code from Java that has a very long string split into parts, concatenated on different lines like so: {code:java} String concatenated = "This is part 1" + "This is part 2" + "This is part 3";{code} This is a very common occurrence, and in Groovy it results in a weird syntax error. I am well aware that I can add "\" at the end of the line to continue the statement, but this does not really solve the core issue. According to GROOVY-6476, this is not considered a problem, but in other scripting languages, where semicolons are optional, like JavaScript, both of these examples work as expected - {{sum}} is equal to "4", and the string is concatenated. It would be nice if the parser considers adding the expressions that begin on the next line to the statement that has been started on the previous line for such common cases. For example, if the line does not end with a semicolon, then look at the first token on the next line and see if it is an operator. If it is, then continue the statement, instead of terminating it implicitly at the end of the line. -- This message was sent by Atlassian Jira (v8.3.4#803005)