Issue Details (XML | Word | Printable)

Key: GROOVY-2101
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: Russel Winder
Votes: 0
Watchers: 0
Operations

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

Error message needs changing

Created: 06/Sep/07 12:33 AM   Updated: 02/Nov/07 08:22 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1-rc-2

Time Tracking:
Not Specified

Environment: Ubuntu 7.04 Feisty Fawn + Groovy SVN HEAD


 Description  « Hide
if the script:
data = [ 3 , 4 , 5 ]
doSomething = { i -> println ( i ) }
data.each doSomething

is in a file named doSomething.groovy then the resulting error message is:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, doSomething.groovy: 2: you tried to assign a value to doSomething
@ line 2, column 1.
doSomething = { i -> println ( i ) }
^

1 error

this is not particularly informative. The "error" is actually that the script is called doSomething.groovy so the generated class will be called doSomething and so it is not possible to put a varaible of this name into the binding. So the message should be something like: "The script is called doSomething so it is not possible to have variables of that name in the binding."



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King added a comment - 20/Oct/07 06:21 AM
now says:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, doSomething.groovy: 2: you tried to assign a value to the class 'doSomething'

Russel Winder added a comment - 31/Oct/07 02:41 AM
I just updated to r8944 and tried running the script and got:
> ./doSomething.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, ./doSomething.groovy: 6: you tried to assign a value to the class 'doSomething'
@ line 6, column 1.
doSomething = { i -> println ( i ) }
^

1 error

So I guess there has been a reversion somewhere along the line.


Russel Winder added a comment - 31/Oct/07 02:44 AM
Sorry, I should read the error meesage completely. The message has of course changed.

However, the message does require people to know that the name of the script is the name of the class that the script becomes. If we are happy with this requirement then I will just close this issue as fixed.


Paul King added a comment - 31/Oct/07 06:18 AM
Now if it looks like a script it says:
you tried to assign a value to the class 'testBits'. Do you have a script with this name?

Russel Winder added a comment - 02/Nov/07 08:22 AM
OK, that works for me