History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-1742
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Paul King
Reporter: Michael Koch
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Change compiler error message "Closure expression looks like it may be an isolated open block" to make it more clear

Created: 22/Feb/07 01:17 AM   Updated: 08/Feb/08 01:26 AM
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.5.2

Time Tracking:
Not Specified


 Description  « Hide
Running { println "foo" }

in the groovyConsole results in the compiler error message "Closure expression looks like it may be an isolated open block.;
solution: Add an explicit parameter list, as in {it -> ...}, or label it as L:{...}.". For me as a groovy newbie it wasn't clear that the first solution marks the code as closure while the second marks it as block, I thought that both would result in a closure. Perhaps the wording should be changed to something like this:

"Expression could be either a closure expression or an isolated open block. Solution: Add an explicit parameter list, as in {it -> ...}, to create a closure or label it as L:{...} to mark it as block."



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Russel Winder - 26/Jul/07 05:19 AM
Is there anything that can usefully be done to improve Groovy with respect to this issue?

Russel Winder - 16/Dec/07 02:33 AM
This also affects 1.5.0.

Is there a phrasing of the message that makes things clearer?


Paul King - 30/Dec/07 04:08 PM
Now says:
Ambiguous expression could be either a parameterless closure expression or an isolated open code block;
   solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...}

not perfect but probably as good as we will get for now.


Paul King - 08/Feb/08 01:26 AM
close off release 1.5.4