Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-beta-1
-
None
Description
The parser fails to parse the following code:
class Test { public void test() { [1, 2, 3, 4, 5].stream().forEach(num -> println "$num"); } }
The produced error is:
Exception in thread "main" org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script_30c2a85fbeaac50f95df1e8ce776b5dd.groovy: 4: Unexpected input: '(' @ line 4, column 41. , 2, 3, 4, 5].stream().forEach(num -> pr ^
This problem appears only after 4.0.0-beta-1.
The following expressions are parsed successfully:
[1, 2, 3, 4, 5].stream().forEach(num -> { println "$num" }); [1, 2, 3, 4, 5].stream().forEach(num -> println("$num"));
There is also something curious: if I modify the original code and wrap the parameter num in parentheses (.forEach((num) -> println "$num")), the parser does not complain, but println is recognized as a variable rather than a method.