[ 
https://issues.apache.org/jira/browse/GROOVY-9213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun resolved GROOVY-9213.
--------------------------------
    Resolution: Fixed

> Parser runs (possibly) endless loop for unclosed parenthesis followed by many 
> expressions/statements
> ----------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9213
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9213
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser-antlr2, parser-antlr4
>            Reporter: Eric Milles
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 7.0.0-alpha-1
>
>
> Consider the following:
> {code:groovy}
> int a = 0
> // insert ( here instead of this comment and try to select anything below
> a = 0
> a = 0
> a = 0
> ... (like 50 times)
> {code}
> With the unmatched parenthesis inserted at line 2, there is a loop in the 
> parser looking for command arguments.
> Here is a test case that demonstrates:
> {code:groovy}
> import groovy.transform.CompileStatic
> import org.codehaus.groovy.control.CompilerConfiguration
> import org.junit.Test
> import static org.codehaus.groovy.control.ParserPluginFactory.antlr2
> import static org.codehaus.groovy.control.ParserPluginFactory.antlr4
> @CompileStatic
> final class Groovy9213 {
>     @Test(timeout=15000L)
>     void testUnmatchedParenInLongScript2() {
>         def config = new CompilerConfiguration()
>         config.pluginFactory = antlr2()
>         new GroovyShell(config).evaluate('''
>             int a = 0
>             (
>         ''' + ('a = 0\n' * 50))
>     }
>     @Test(timeout=15000L)
>     void testUnmatchedParenInLongScript4() {
>         def config = new CompilerConfiguration()
>         config.pluginFactory = antlr4(config)
>         new GroovyShell(config).evaluate('''
>             int a = 0
>             (
>         ''' + ('a = 0\n' * 50))
>     }
> }
> {code}
> This is a problem for users editing Groovy scripts in the IDE: 
> https://github.com/groovy/groovy-eclipse/issues/932



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to