groovy

Error message needs changing

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.1-rc-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Ubuntu 7.04 Feisty Fawn + Groovy SVN HEAD
  • Number of attachments :
    0

Description

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."

Activity

Hide
Paul King added a comment -

now says:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, doSomething.groovy: 2: you tried to assign a value to the class 'doSomething'
Show
Paul King added a comment - now says:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, doSomething.groovy: 2: you tried to assign a value to the class 'doSomething'
Hide
Russel Winder added a comment -

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.

Show
Russel Winder added a comment - 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.
Hide
Russel Winder added a comment -

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.

Show
Russel Winder added a comment - 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.
Hide
Paul King added a comment -

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?
Show
Paul King added a comment - 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?
Hide
Russel Winder added a comment -

OK, that works for me

Show
Russel Winder added a comment - OK, that works for me

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: