You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2026/08/21 20:40:00 UTC

[jira] [Resolved] (GROOVY-10355) Compiler interpret variable name as class name when in parentheses.

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

Paul King resolved GROOVY-10355.
--------------------------------
    Fix Version/s: 6.0.0-beta-3
         Assignee: Paul King
       Resolution: Fixed

> Compiler interpret variable name  as class name when in parentheses.
> --------------------------------------------------------------------
>
>                 Key: GROOVY-10355
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10355
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser-antlr4
>    Affects Versions: 3.0.0, 4.0.0, 5.0.0
>         Environment: JDK 11.0.12
>            Reporter: Olof Asbrink
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 6.0.0-beta-3
>
>         Attachments: GROOVY-10355-Assessment.pdf, screenshot-1.png, screenshot-2.png
>
>
> This behavior seems unexpected:
> {code:java}
> String b = "B"
> System.out.println("A" + (b) + "C")
> {code}
> Throws this exception:
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> /tmp/repo1.gm: 2: unable to resolve class b
>  @ line 2, column 26.
>    System.out.println("A" + (b) + "C")
>                             ^{code}
> However these examples work:
> {code:java}
> String b = "B"
> System.out.println("A" + b + "C")
> {code}
> and
> {code:java}
> String b = "B"
> System.out.println("A" + (b))
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)