You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Moy <dy...@gmail.com> on 2018/07/04 03:00:18 UTC

https://issues.apache.org/jira/browse/GROOVY-8678

Hi,

I reported bug metioned in the subject as I was not able to ascertain from
the web if what I am facing is a consequence of desired intent.

Paul King
<https://issues.apache.org/jira/secure/ViewProfile.jspa?name=paulk>
 suggested  to check issue with the mailing list. Here I am following the
suggestion.


Using groovy shell to execute the following groovy script snippet fails at
compilation phase when executing the script through java. I am using Jre1.7

public static void main(String[] args) throws Exception,
IllegalAccessException { Object evaluate = new
GroovyShell().evaluate("\"abcd\".length() == .34");
System.out.println("result: " + evaluate);
}

 In the above snippet, If I replace *.34* with *0.34* then the script
execution works as expected.

Exception reported is as follows

Exception in thread "main"
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
Script1.groovy: 1: unexpected token: . @ line 1, column
20."abcd".length() == .34
^

1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:311)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:151)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:121)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:133)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:332)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:226)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:192)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:230)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:186)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:968)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:352)
at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:85)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:321)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:318)
at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:316)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:548)
at groovy.lang.GroovyShell.parse(GroovyShell.java:560)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:444)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:483)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:454)
at groovytest.Testtest.main(Testtest.java:19)



Please let me know if this problem will be fixed, if so which release and
when is the release date.



-- 
Regards
Dyutimoy  Sarkar

Re: https://issues.apache.org/jira/browse/GROOVY-8678

Posted by Jochen Theodorou <bl...@gmx.org>.

Am 04.07.2018 um 05:00 schrieb Moy:
> Hi,
> 
> I reported bug metioned in the subject as I was not able to ascertain 
> from the web if what I am facing is a consequence of desired intent.
> 
> Paul King 
> <https://issues.apache.org/jira/secure/ViewProfile.jspa?name=paulk> suggested to 
> check issue with the mailing list. Here I am following the suggestion.
> 
> 
> Using groovy shell to execute the following groovy script snippet fails 
> at compilation phase when executing the script through java. I am using 
> Jre1.7
> 
> public  static  void main(String[] args)throws  Exception, IllegalAccessException {Object  evaluate =new  GroovyShell().evaluate("\"abcd\".length() == .34");System.out.println("result: "  + evaluate);
> }
> 
>   In the above snippet, If I replace*.34* with*0.34* then the script 
> execution works as expected.

.34 is no valid decimal in Groovy.

[...]
> Please let me know if this problem will be fixed, if so which release 
> and when is the release date.

it is intentional not allowed to use .34. Unless you give a very good 
reason for why it should be allowed there will most likely be no fix.

bye Jochen