groovy

+ operator on null string concat causes exception

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-1
  • Fix Version/s: 1.1-beta-2
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows 2000, groovy 1.0 jsr-1, jdk 1.4
  • Number of attachments :
    0

Description

The following program produces an error:

"
class Employee {
String name
int empId

String toString() { return name + ": " + empId }
}

e = new Employee()
println e
"

The error is "Cannot invoke method: plus on null object". What I expect to see is "null: 0". I can see why this is happening but I don't know the best way to fix it.

Another issue is that when anything goes wrong in groovy, I get a big stacktrace, java style. As a user of the system, I'd rather just see a concise one line error.

Thanks, keep up the good work. I'm certainly going to keep my eye on this language.
JJ Furman

Activity

Hide
Paul King added a comment -

I don't know when this changed, but in HEAD this now prints:

null: 0

Show
Paul King added a comment - I don't know when this changed, but in HEAD this now prints: null: 0
Hide
Paul King added a comment -

No further feedback, assuming fixed

Show
Paul King added a comment - No further feedback, assuming fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: