Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.0.0-alpha-3
-
None
-
None
-
Windows, Java 1.8.0_152
Description
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'):
def a = var / 10 // return bla return a
This crashes with MissingPropertyException (not found: foo):
def a = foo / 10 // return bla return a
This crashes with MissingPropertyException (not found: var):
def a = var / 10 return a
This crashes with MissingPropertyException (not found: What):
def a = var / 10 // What is happening return a
Works:
def var = 10 def a = var / 10 return a
This crashes with MultipleCompilationErrorsException (Unexpected input: '?')
def var = 10 def a = var / 10 // What? return a
Works:
def foo = 10 def a = foo / 10 // What? return a
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'.