[
https://issues.apache.org/jira/browse/GROOVY-8734?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun resolved GROOVY-8734.
--------------------------------
Resolution: Fixed
> 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
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 7.0.0-alpha-1
>
>
> 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
(v10.3.26#10030026)