groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8810) Groovy doesn't support concatenation symbol at line start
Date Tue, 25 Sep 2018 18:26:00 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16627764#comment-16627764
] 

Paul King commented on GROOVY-8810:
-----------------------------------

The + is currently by design. The following:
{code}
+foo
-foo
{code}
Are unary operators:
{code}
unaryPlus(foo)
unaryMinus(foo)
{code}
So for backwards compatibility we didn't support them when enabling various lookahead for
 expressions which might span multiple lines.

I'd love to see if we can come up with an improved process for handling this scenario. But
it would be a breaking change, i.e. Groovy 3 or above only and we'd need a GEP.
Note there are a couple of other cases where our behavior is slightly different between 2.x
and 3.0. There are a couple of Jiras I believe.

> Groovy doesn't support concatenation symbol at line start
> ---------------------------------------------------------
>
>                 Key: GROOVY-8810
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8810
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>            Reporter: ori marko
>            Priority: Major
>
> Groovy doesn't support concatenation using + or << *at line start*,
> Use case: Need to concatenate a many variables and want to make it readable, but failed
to separate lines similar to  java
> 1. Java supported code:
> String text= "0"+"1" +
> "2" 
> +"3";
>  
> Error:
> javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method:
java.lang.String.positive() is applicable for argument types: () values: []
> Possible solutions: notify(), tokenize(), size(), size()
>  
> 2. groovy concatenation split in new line(s):
> {{String text ="<id>" <<vars["id1"] << "<id><id2>" }}
> {{<< vars["id2"] << "<id2>";}}
> {{Error:}}
> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>    << vars["id2"] << "<id2>"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message