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] [Updated] (GROOVY-8734) Using 'var' in operation followed by comment fails compilation
Date Wed, 08 Aug 2018 14:22:00 GMT

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

Paul King updated GROOVY-8734:
------------------------------
    Component/s: parser-antlr4

> Using 'var' in operation followed by comment fails compilation
> --------------------------------------------------------------
>
>                 Key: GROOVY-8734
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8734
>             Project: Groovy
>          Issue Type: Bug
>          Components: lexer, parser-antlr4
>    Affects Versions: 3.0.0-alpha-3
>         Environment: Windows, Java 1.8.0_152
>            Reporter: Pontus
>            Priority: Major
>
> There seems to be some issue with scripting containing variables called "var" and then
followed by a comment.
> This crashes with MultipleCompilationErrorsException (unexpected input 'return'):
> {code:java}
> def a = var / 10
> // return bla
> return a{code}
> This crashes with MissingPropertyException (not found: foo):
> {code:java}
> def a = foo / 10
> // return bla
> return a
> {code}
> This crashes with MissingPropertyException (not found: var):
> {code:java}
> def a = var / 10
> return a
> {code}
> This crashes with MissingPropertyException (not found: What):
> {code:java}
> def a = var / 10
> // What is happening
> return a
> {code}
> Works:
> {code:java}
> def var = 10
> def a = var / 10
> return a
> {code}
> This crashes with MultipleCompilationErrorsException (Unexpected input: '?')
> {code:java}
> def var = 10
> def a = var / 10
> // What?
> return a
> {code}
> Works:
> {noformat}
> def foo = 10
> def a = foo / 10
> // What?
> return a{noformat}
> I did not know that "var" was handled by Groovy. But anyway, seems something is quite
off with it. We noticed this after upgrading from Groovy 2.x to 3, where the script used to
work in 2.x.
> I can see in the lexer that the tokens that are recognized become really weird, with
everything between "var / [..] /" becomes one token, then "/ return" fails since you of course
cannot divide by 'return'.



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

Mime
View raw message