Issue Details (XML | Word | Printable)

Key: GROOVY-1891
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Peter Niederwieser
Votes: 1
Watchers: 0
Operations

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

Assignment to array element yields null

Created: 12/May/07 04:24 PM   Updated: 01/Jul/07 05:54 PM
Component/s: bytecode
Affects Version/s: 1.0, 1.1-beta-1
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Environment: Windows XP
Java SE 6

Testcase included: yes


 Description  « Hide
Assigning a value to an array element yields null instead of the assigned value.

int[] a = new int[1]
assert (a[0] = 42) == null // current behavior
assert (a[0] = 42) == 42 // expected behavior



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Peter Niederwieser added a comment - 17/May/07 08:24 AM
I suggest to keep putAt() a "void" method and just make a[0]=42 evaluate to 42 rather than null. This is consistent with properties, where setters have return type void and therefore a.setX(42) evaluates to null, whereas a.x=42 evaluates to 42.

Jochen Theodorou added a comment - 01/Jul/07 05:54 PM
implemented